board.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * Copyright (c) 2006-2018, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. */
  9. #include <rthw.h>
  10. #include <rtthread.h>
  11. #include "board.h"
  12. #include "tick.h"
  13. #include "drv_uart.h"
  14. #include "encoding.h"
  15. #include "fpioa.h"
  16. #include "dmac.h"
  17. #include "uarths.h"
  18. void rt_hw_console_output(const char *str)
  19. {
  20. uarths_puts(str);
  21. return ;
  22. }
  23. void init_bss(void)
  24. {
  25. unsigned int *dst;
  26. dst = &__bss_start;
  27. while (dst < &__bss_end)
  28. {
  29. *dst++ = 0;
  30. }
  31. }
  32. void cpu_entry(int cpuid)
  33. {
  34. extern void entry(void);
  35. /* disable global interrupt */
  36. rt_hw_interrupt_disable();
  37. if (cpuid == 0)
  38. {
  39. init_bss();
  40. entry();
  41. }
  42. else
  43. {
  44. while (1) ;
  45. }
  46. }
  47. #include <clint.h>
  48. #include <sysctl.h>
  49. int freq(void)
  50. {
  51. rt_uint64_t value = 0;
  52. value = sysctl_clock_get_freq(SYSCTL_CLOCK_PLL0);
  53. rt_kprintf("PLL0: %d\n", value);
  54. value = sysctl_clock_get_freq(SYSCTL_CLOCK_PLL1);
  55. rt_kprintf("PLL1: %d\n", value);
  56. value = sysctl_clock_get_freq(SYSCTL_CLOCK_PLL2);
  57. rt_kprintf("PLL2: %d\n", value);
  58. value = sysctl_clock_get_freq(SYSCTL_CLOCK_CPU);
  59. rt_kprintf("CPU : %d\n", value);
  60. value = sysctl_clock_get_freq(SYSCTL_CLOCK_APB0);
  61. rt_kprintf("APB0: %d\n", value);
  62. value = sysctl_clock_get_freq(SYSCTL_CLOCK_APB1);
  63. rt_kprintf("APB1: %d\n", value);
  64. value = sysctl_clock_get_freq(SYSCTL_CLOCK_APB2);
  65. rt_kprintf("APB2: %d\n", value);
  66. value = sysctl_clock_get_freq(SYSCTL_CLOCK_HCLK);
  67. rt_kprintf("HCLK: %d\n", value);
  68. value = clint_get_time();
  69. rt_kprintf("mtime: %d\n", value);
  70. return 0;
  71. }
  72. MSH_CMD_EXPORT(freq, show freq info);
  73. void rt_hw_board_init(void)
  74. {
  75. /* Init FPIOA */
  76. fpioa_init();
  77. /* Dmac init */
  78. dmac_init();
  79. /* initalize interrupt */
  80. rt_hw_interrupt_init();
  81. /* initialize hardware interrupt */
  82. rt_hw_uart_init();
  83. rt_hw_tick_init();
  84. #ifdef RT_USING_CONSOLE
  85. /* set console device */
  86. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  87. #endif /* RT_USING_CONSOLE */
  88. #ifdef RT_USING_HEAP
  89. rt_kprintf("heap: [0x%08x - 0x%08x]\n", (rt_ubase_t) RT_HW_HEAP_BEGIN, (rt_ubase_t) RT_HW_HEAP_END);
  90. /* initialize memory system */
  91. rt_system_heap_init(RT_HW_HEAP_BEGIN, RT_HW_HEAP_END);
  92. #endif
  93. #ifdef RT_USING_COMPONENTS_INIT
  94. rt_components_board_init();
  95. #endif
  96. }