board.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. * 2019-07-23 tyustli first version
  9. *
  10. */
  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. /* set value */
  20. *(rt_uint64_t *) (TMR_CTRL_ADDR + TMR_MTIMECMP) = ticks;
  21. /* enable interrupt */
  22. eclic_irq_enable(CLIC_INT_TMR, 0, 0);
  23. /* clear value */
  24. *(rt_uint64_t *) (TMR_CTRL_ADDR + TMR_MTIME) = 0;
  25. }
  26. /* This is the timer interrupt service routine. */
  27. void eclic_mtip_handler(void) {
  28. /* clear value */
  29. *(rt_uint64_t *) (TMR_CTRL_ADDR + TMR_MTIME) = 0;
  30. /* enter interrupt */
  31. rt_interrupt_enter();
  32. /* tick increase */
  33. rt_tick_increase();
  34. /* leave interrupt */
  35. rt_interrupt_leave();
  36. }
  37. void rt_hw_board_init(void) {
  38. systick_config(TMR_FREQ / RT_TICK_PER_SECOND);
  39. #ifdef RT_USING_HEAP
  40. rt_system_heap_init((void *) HEAP_BEGIN, (void *) HEAP_END);
  41. #endif
  42. /* USART driver initialization is open by default */
  43. #ifdef RT_USING_SERIAL
  44. rt_hw_usart_init();
  45. #endif
  46. /* Set the shell console output device */
  47. #ifdef RT_USING_CONSOLE
  48. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  49. #endif
  50. /* Board underlying hardware initialization */
  51. #ifdef RT_USING_COMPONENTS_INIT
  52. rt_components_board_init();
  53. #endif
  54. }
  55. /******************** end of file *******************/