board.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright (c) 2006-2020, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2021-02-11 supperthomas first version
  9. *
  10. */
  11. #include <rtthread.h>
  12. #include <rthw.h>
  13. #include <stdio.h>
  14. #include "board.h"
  15. #include "mxc_sys.h"
  16. #ifdef RT_USING_SERIAL
  17. #include "drv_usart.h"
  18. #endif
  19. /**
  20. * This is the timer interrupt service routine.
  21. *
  22. */
  23. void SysTick_Handler(void)
  24. {
  25. /* enter interrupt */
  26. rt_interrupt_enter();
  27. rt_tick_increase();
  28. /* leave interrupt */
  29. rt_interrupt_leave();
  30. }
  31. void rt_hw_systick_init(void)
  32. {
  33. uint32_t error;
  34. error = SYS_SysTick_Config(SYS_SysTick_GetFreq() / RT_TICK_PER_SECOND, 1, MXC_TMR0);
  35. if (error != E_NO_ERROR)
  36. {
  37. rt_kprintf("ERROR: Ticks is not valid");
  38. }
  39. }
  40. void rt_hw_board_init(void)
  41. {
  42. rt_hw_systick_init();
  43. #if defined(RT_USING_HEAP)
  44. rt_system_heap_init((void *)(HEAP_BEGIN), (void *)(HEAP_END));
  45. #endif
  46. #ifdef RT_USING_SERIAL
  47. rt_hw_usart_init();
  48. #endif
  49. #ifdef RT_USING_CONSOLE
  50. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  51. #endif
  52. #ifdef RT_USING_COMPONENTS_INIT
  53. rt_components_board_init();
  54. #endif
  55. }