board.c 1.7 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. * 2023-07-15 yby the first version
  9. */
  10. #include "board.h"
  11. void uart_hw_config(void)
  12. {
  13. #ifdef BSP_USING_UART0
  14. SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
  15. SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
  16. GPIOPinConfigure(GPIO_PA0_U0RX);
  17. GPIOPinConfigure(GPIO_PA1_U0TX);
  18. GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
  19. #endif
  20. }
  21. /* this funtion set the Systick and enable systick int */
  22. void SystemClock_Config()
  23. {
  24. /* System Clock Update */
  25. SystemCoreClockUpdate();
  26. SysTickDisable();
  27. SysTickPeriodSet(SystemCoreClock / RT_TICK_PER_SECOND);
  28. SysTickIntEnable();
  29. SysTickEnable();
  30. }
  31. /**
  32. * This function will initial your board.
  33. */
  34. void rt_hw_board_init()
  35. {
  36. /* System clock initialization */
  37. SystemClock_Config();
  38. /* Heap initialization */
  39. #if defined(RT_USING_HEAP)
  40. rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
  41. #endif
  42. /* Pin driver initialization is open by default */
  43. #ifdef RT_USING_PIN
  44. rt_hw_pin_init();
  45. #endif
  46. /* USART driver initialization is open by default */
  47. #ifdef RT_USING_SERIAL
  48. rt_hw_usart_init();
  49. #endif
  50. /* Set the shell console output device */
  51. #if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
  52. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  53. #endif
  54. /* Board underlying hardware initialization */
  55. #ifdef RT_USING_COMPONENTS_INIT
  56. rt_components_board_init();
  57. #endif
  58. }
  59. void SysTick_Handler(void)
  60. {
  61. /* enter interrupt */
  62. rt_interrupt_enter();
  63. rt_tick_increase();
  64. /* leave interrupt */
  65. rt_interrupt_leave();
  66. }