1
0

board.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright (c) 2006-2021, 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 "drv_uart.h"
  13. #include "cp15.h"
  14. void rt_hw_timer_isr(int vector, void *parameter)
  15. {
  16. ARM_TIMER_IRQCLR = 0;
  17. rt_tick_increase();
  18. }
  19. int rt_hw_timer_init(void)
  20. {
  21. /* timer_clock = apb_clock/(pre_divider + 1) */
  22. ARM_TIMER_PREDIV = (250 - 1);
  23. ARM_TIMER_RELOAD = 0;
  24. ARM_TIMER_LOAD = 0;
  25. ARM_TIMER_IRQCLR = 0;
  26. ARM_TIMER_CTRL = 0;
  27. ARM_TIMER_RELOAD = 10000;
  28. ARM_TIMER_LOAD = 10000;
  29. /* 23-bit counter, enable interrupt, enable timer */
  30. ARM_TIMER_CTRL = (1 << 1) | (1 << 5) | (1 << 7);
  31. rt_hw_interrupt_install(IRQ_ARM_TIMER, rt_hw_timer_isr, RT_NULL, "tick");
  32. rt_hw_interrupt_umask(IRQ_ARM_TIMER);
  33. return 0;
  34. }
  35. void vector_copy(void)
  36. {
  37. rt_memcpy((void*)0x0, (void*)0x8000, 64);
  38. }
  39. void rt_hw_board_init(void)
  40. {
  41. /* initialize hardware interrupt */
  42. rt_hw_interrupt_init();
  43. rt_hw_vector_init();
  44. /* initialize uart */
  45. rt_hw_uart_init();
  46. #ifdef RT_USING_CONSOLE
  47. /* set console device */
  48. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  49. #endif /* RT_USING_CONSOLE */
  50. #ifdef RT_USING_HEAP
  51. /* initialize memory system */
  52. rt_kprintf("heap: 0x%08x - 0x%08x\n", RT_HW_HEAP_BEGIN, RT_HW_HEAP_END);
  53. rt_system_heap_init(RT_HW_HEAP_BEGIN, RT_HW_HEAP_END);
  54. #endif
  55. /* initialize timer for os tick */
  56. rt_hw_timer_init();
  57. #ifdef RT_USING_COMPONENTS_INIT
  58. rt_components_board_init();
  59. #endif
  60. }