main.c 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * File : clock.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2017-10-10 Tanek first version
  23. */
  24. #include <stdint.h>
  25. #include <rthw.h>
  26. #include <rtthread.h>
  27. #ifdef RT_USING_DFS
  28. #include <dfs_file.h>
  29. #endif
  30. #include <board.h>
  31. RT_USED MPU_Type *mpu = MPU;
  32. RT_USED IOMUXC_GPR_Type *iomuxc_gpr = IOMUXC_GPR;
  33. static void dump_clock(void)
  34. {
  35. rt_kprintf("CPU clock: %d\n", CLOCK_GetFreq(kCLOCK_CpuClk));
  36. rt_kprintf("AHB clock : %d\n", CLOCK_GetFreq(kCLOCK_AhbClk));
  37. rt_kprintf("SEMC clock : %d\n", CLOCK_GetFreq(kCLOCK_SemcClk));
  38. rt_kprintf("IPG clock : %d\n", CLOCK_GetFreq(kCLOCK_IpgClk));
  39. rt_kprintf("OSC clock selected : %d\n", CLOCK_GetFreq(kCLOCK_OscClk));
  40. rt_kprintf("RTC clock: %d\n", CLOCK_GetFreq(kCLOCK_RtcClk));
  41. rt_kprintf("ARMPLLCLK : %d\n", CLOCK_GetFreq(kCLOCK_ArmPllClk));
  42. rt_kprintf("USB1PLLCLK : %d\n", CLOCK_GetFreq(kCLOCK_Usb1PllClk));
  43. rt_kprintf("USB1PLLPDF0CLK : %d\n", CLOCK_GetFreq(kCLOCK_Usb1PllPfd0Clk));
  44. rt_kprintf("USB1PLLPFD1CLK : %d\n", CLOCK_GetFreq(kCLOCK_Usb1PllPfd1Clk));
  45. rt_kprintf("USB1PLLPFD2CLK : %d\n", CLOCK_GetFreq(kCLOCK_Usb1PllPfd2Clk));
  46. rt_kprintf("USB1PLLPFD3CLK : %d\n", CLOCK_GetFreq(kCLOCK_Usb1PllPfd3Clk));
  47. rt_kprintf("USB2PLLCLK : %d\n", CLOCK_GetFreq(kCLOCK_Usb2PllClk));
  48. rt_kprintf("SYSPLLCLK : %d\n", CLOCK_GetFreq(kCLOCK_SysPllClk));
  49. rt_kprintf("SYSPLLPDF0CLK : %d\n", CLOCK_GetFreq(kCLOCK_SysPllPfd0Clk));
  50. rt_kprintf("SYSPLLPFD1CLK : %d\n", CLOCK_GetFreq(kCLOCK_SysPllPfd1Clk));
  51. rt_kprintf("SYSPLLPFD2CLK : %d\n", CLOCK_GetFreq(kCLOCK_SysPllPfd2Clk));
  52. rt_kprintf("SYSPLLPFD3CLK : %d\n", CLOCK_GetFreq(kCLOCK_SysPllPfd3Clk));
  53. rt_kprintf("Enet PLLCLK ref_enetpll0 : %d\n", CLOCK_GetFreq(kCLOCK_EnetPll0Clk));
  54. rt_kprintf("Enet PLLCLK ref_enetpll1 : %d\n", CLOCK_GetFreq(kCLOCK_EnetPll1Clk));
  55. rt_kprintf("Enet PLLCLK ref_enetpll2 : %d\n", CLOCK_GetFreq(kCLOCK_EnetPll2Clk));
  56. rt_kprintf("Audio PLLCLK : %d\n", CLOCK_GetFreq(kCLOCK_AudioPllClk));
  57. rt_kprintf("Video PLLCLK : %d\n", CLOCK_GetFreq(kCLOCK_VideoPllClk));
  58. }
  59. void dump_tcm(void)
  60. {
  61. #define DUMP_REG(__REG) \
  62. rt_kprintf("%s(%08p): %08x\n", #__REG, &(__REG), __REG)
  63. DUMP_REG(IOMUXC_GPR->GPR14);
  64. DUMP_REG(IOMUXC_GPR->GPR16);
  65. DUMP_REG(IOMUXC_GPR->GPR17);
  66. }
  67. int main(void)
  68. {
  69. //dump_clock();
  70. //dump_tcm();
  71. rt_thread_delay(RT_TICK_PER_SECOND * 2);
  72. /* mount sd card fat partition 1 as root directory */
  73. if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
  74. rt_kprintf("File System initialized!\n");
  75. else
  76. rt_kprintf("File System init failed!\n");
  77. while (1)
  78. {
  79. rt_thread_delay(RT_TICK_PER_SECOND);
  80. }
  81. }
  82. /*@}*/