board.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. * 2018/11/29 Bernard the first version
  9. */
  10. #include <rthw.h>
  11. #include <rtthread.h>
  12. #include "board.h"
  13. #include "drv_uart.h"
  14. #include "pin_mux.h"
  15. #include "clock_config.h"
  16. #include <fsl_clock.h>
  17. #include <fsl_intmux.h>
  18. void LPIT0_IRQHandler(void)
  19. {
  20. rt_tick_increase();
  21. SystemClearSystickFlag();
  22. }
  23. int rt_hw_systick_init(void)
  24. {
  25. CLOCK_SetIpSrc(kCLOCK_Lpit0, kCLOCK_IpSrcFircAsync);
  26. SystemSetupSystick (RT_TICK_PER_SECOND, 0);
  27. SystemClearSystickFlag();
  28. return 0;
  29. }
  30. const scg_lpfll_config_t g_appScgLpFllConfig_BOARD_BootClockRUN = {
  31. .enableMode = kSCG_LpFllEnable, /* LPFLL clock disabled */
  32. .div1 = kSCG_AsyncClkDivBy1, /* Low Power FLL Clock Divider 1: Clock output is disabled */
  33. .div2 = kSCG_AsyncClkDisable, /* Low Power FLL Clock Divider 2: Clock output is disabled */
  34. .div3 = kSCG_AsyncClkDisable, /* Low Power FLL Clock Divider 3: Clock output is disabled */
  35. .range = kSCG_LpFllRange72M, /* LPFLL is trimmed to 72MHz */
  36. .trimConfig = NULL,
  37. };
  38. void rt_hw_board_init(void)
  39. {
  40. BOARD_InitPins();
  41. BOARD_BootClockRUN();
  42. /* Init LPFLL */
  43. CLOCK_InitLpFll(&g_appScgLpFllConfig_BOARD_BootClockRUN);
  44. INTMUX_Init(INTMUX0);
  45. INTMUX_EnableInterrupt(INTMUX0, 0, PORTC_IRQn);
  46. /* initialize hardware interrupt */
  47. rt_hw_uart_init();
  48. rt_hw_systick_init();
  49. #ifdef RT_USING_CONSOLE
  50. /* set console device */
  51. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  52. #endif /* RT_USING_CONSOLE */
  53. #ifdef RT_USING_HEAP
  54. /* initialize memory system */
  55. rt_system_heap_init(RT_HW_HEAP_BEGIN, RT_HW_HEAP_END);
  56. #endif
  57. #ifdef RT_USING_COMPONENTS_INIT
  58. rt_components_board_init();
  59. #endif
  60. }