main.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. #ifdef RT_USING_DEVICE
  31. #include <rtdevice.h>
  32. #endif
  33. #include <board.h>
  34. void dump_clock(void)
  35. {
  36. rt_kprintf("OSC clock : %d\n", CLOCK_GetFreq(kCLOCK_OscClk));
  37. rt_kprintf("RTC clock : %d\n", CLOCK_GetFreq(kCLOCK_RtcClk));
  38. rt_kprintf("CPU clock: %d\n", CLOCK_GetFreq(kCLOCK_CpuClk));
  39. rt_kprintf("AHB clock : %d\n", CLOCK_GetFreq(kCLOCK_AhbClk));
  40. rt_kprintf("SEMC clock : %d\n", CLOCK_GetFreq(kCLOCK_SemcClk));
  41. rt_kprintf("IPG clock : %d\n", CLOCK_GetFreq(kCLOCK_IpgClk));
  42. rt_kprintf("ARMPLLCLK(PLL1) : %d\n", CLOCK_GetFreq(kCLOCK_ArmPllClk));
  43. rt_kprintf("SYSPLLCLK(PLL2/528_PLL) : %d\n", CLOCK_GetFreq(kCLOCK_SysPllClk));
  44. rt_kprintf("SYSPLLPDF0CLK : %d\n", CLOCK_GetFreq(kCLOCK_SysPllPfd0Clk));
  45. rt_kprintf("SYSPLLPFD1CLK : %d\n", CLOCK_GetFreq(kCLOCK_SysPllPfd1Clk));
  46. rt_kprintf("SYSPLLPFD2CLK : %d\n", CLOCK_GetFreq(kCLOCK_SysPllPfd2Clk));
  47. rt_kprintf("SYSPLLPFD3CLK : %d\n", CLOCK_GetFreq(kCLOCK_SysPllPfd3Clk));
  48. rt_kprintf("USB1PLLCLK(PLL3) : %d\n", CLOCK_GetFreq(kCLOCK_Usb1PllClk));
  49. rt_kprintf("USB1PLLPDF0CLK : %d\n", CLOCK_GetFreq(kCLOCK_Usb1PllPfd0Clk));
  50. rt_kprintf("USB1PLLPFD1CLK : %d\n", CLOCK_GetFreq(kCLOCK_Usb1PllPfd1Clk));
  51. rt_kprintf("USB1PLLPFD2CLK : %d\n", CLOCK_GetFreq(kCLOCK_Usb1PllPfd2Clk));
  52. rt_kprintf("USB1PLLPFD3CLK : %d\n", CLOCK_GetFreq(kCLOCK_Usb1PllPfd3Clk));
  53. rt_kprintf("Audio PLLCLK(PLL4) : %d\n", CLOCK_GetFreq(kCLOCK_AudioPllClk));
  54. rt_kprintf("Video PLLCLK(PLL5) : %d\n", CLOCK_GetFreq(kCLOCK_VideoPllClk));
  55. rt_kprintf("Enet PLLCLK ref_enetpll0 : %d\n", CLOCK_GetFreq(kCLOCK_EnetPll0Clk));
  56. rt_kprintf("Enet PLLCLK ref_enetpll1 : %d\n", CLOCK_GetFreq(kCLOCK_EnetPll1Clk));
  57. rt_kprintf("USB2PLLCLK(PLL7) : %d\n", CLOCK_GetFreq(kCLOCK_Usb2PllClk));
  58. }
  59. void dump_cc_info(void)
  60. {
  61. #if defined(__CC_ARM)
  62. rt_kprintf("using armcc, version: %d\n", __ARMCC_VERSION);
  63. #elif defined(__ICCARM__)
  64. rt_kprintf("using iccarm, version: %d\n", __VER__);
  65. #elif defined(__GNUC__)
  66. rt_kprintf("using gcc, version: %d.%d\n", __GNUC__, __GNUC_MINOR__);
  67. #endif
  68. }
  69. void dump_link_info(void)
  70. {
  71. #if defined(__CC_ARM)
  72. #elif defined(__ICCARM__)
  73. #elif defined(__GNUC__)
  74. #define DUMP_SYMBOL(__SYM) \
  75. extern int __SYM; \
  76. rt_kprintf("%s: %p\n", #__SYM, &__SYM)
  77. DUMP_SYMBOL(__fsymtab_start);
  78. DUMP_SYMBOL(__fsymtab_end);
  79. DUMP_SYMBOL(__vsymtab_start);
  80. DUMP_SYMBOL(__vsymtab_end);
  81. DUMP_SYMBOL(__rt_init_start);
  82. DUMP_SYMBOL(__rt_init_end);
  83. DUMP_SYMBOL(__exidx_start);
  84. DUMP_SYMBOL(__exidx_end);
  85. DUMP_SYMBOL(__etext);
  86. DUMP_SYMBOL(__data_start__);
  87. DUMP_SYMBOL(__data_end__);
  88. DUMP_SYMBOL(__noncachedata_start__);
  89. DUMP_SYMBOL(__noncachedata_init_end__);
  90. DUMP_SYMBOL(__noncachedata_end__);
  91. DUMP_SYMBOL(__bss_start__);
  92. DUMP_SYMBOL(__bss_end__);
  93. DUMP_SYMBOL(stack_start);
  94. DUMP_SYMBOL(stack_end);
  95. DUMP_SYMBOL(heap_start);
  96. #endif
  97. }
  98. int main(void)
  99. {
  100. rt_uint32_t result;
  101. //dump_clock();
  102. dump_cc_info();
  103. dump_link_info();
  104. rt_kprintf("build time: %s %s\n", __DATE__, __TIME__);
  105. #if defined(RT_USING_DFS) && defined(RT_USING_SDIO)
  106. result = mmcsd_wait_cd_changed(RT_TICK_PER_SECOND);
  107. if (result == MMCSD_HOST_PLUGED)
  108. {
  109. /* mount sd card fat partition 1 as root directory */
  110. if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
  111. rt_kprintf("File System initialized!\n");
  112. else
  113. rt_kprintf("File System init failed!\n");
  114. }
  115. else
  116. {
  117. rt_kprintf("sdcard init fail or timeout: %d!\n", result);
  118. }
  119. #endif
  120. }
  121. /*@}*/