1
0

board.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * Copyright (c) 2006-2022, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2022-06-04 BruceOu first implementation
  9. */
  10. #include <stddef.h>
  11. #include <rtthread.h>
  12. #include <rtdevice.h>
  13. #include "board.h"
  14. #ifdef RT_USING_SERIAL
  15. #include <drv_usart.h>
  16. #endif
  17. /* System Tick Configuration */
  18. static void systick_config(rt_uint32_t ticks)
  19. {
  20. /* set value */
  21. *(rt_uint64_t *) (TIMER_CTRL_ADDR + TIMER_MTIMECMP) = ticks;
  22. /* enable interrupt */
  23. eclic_irq_enable(CLIC_INT_TMR, 0, 0);
  24. /* clear value */
  25. *(rt_uint64_t *) (TIMER_CTRL_ADDR + TIMER_MTIME) = 0;
  26. }
  27. /* This is the timer interrupt service routine. */
  28. void eclic_mtip_handler(void)
  29. {
  30. /* clear value */
  31. *(rt_uint64_t *) (TIMER_CTRL_ADDR + TIMER_MTIME) = 0;
  32. /* enter interrupt */
  33. rt_interrupt_enter();
  34. /* tick increase */
  35. rt_tick_increase();
  36. /* leave interrupt */
  37. rt_interrupt_leave();
  38. }
  39. /* fixed misaligned bug for qemu */
  40. void *__wrap_memset(void *s, int c, size_t n)
  41. {
  42. return rt_memset(s, c, n);
  43. }
  44. void rt_hw_board_init(void)
  45. {
  46. extern void _init(void);
  47. _init();
  48. systick_config(TIMER_FREQ / RT_TICK_PER_SECOND);
  49. /* USART driver initialization is open by default */
  50. #ifdef RT_USING_SERIAL
  51. rt_hw_usart_init();
  52. #endif
  53. /* Set the shell console output device */
  54. #if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
  55. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  56. #endif
  57. /* Board underlying hardware initialization */
  58. #ifdef RT_USING_COMPONENTS_INIT
  59. rt_components_board_init();
  60. #endif
  61. #ifdef RT_USING_HEAP
  62. rt_system_heap_init((void *) HEAP_BEGIN, (void *) HEAP_END);
  63. #endif
  64. }
  65. /******************** end of file *******************/