board.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. * 2009-01-05 Bernard first implementation
  9. * 2010-02-04 Magicoe ported to LPC17xx
  10. * 2010-05-02 Aozima update CMSIS to 130
  11. */
  12. #include <rthw.h>
  13. #include <rtthread.h>
  14. #include "board.h"
  15. #include "drv_uart.h"
  16. /**
  17. * This is the timer interrupt service routine.
  18. *
  19. */
  20. void SysTick_Handler(void)
  21. {
  22. /* enter interrupt */
  23. rt_interrupt_enter();
  24. rt_tick_increase();
  25. /* leave interrupt */
  26. rt_interrupt_leave();
  27. }
  28. /**
  29. * This function will initial LPC54xx board.
  30. */
  31. void rt_hw_board_init()
  32. {
  33. /* NVIC Configuration */
  34. #define NVIC_VTOR_MASK 0x3FFFFF80
  35. #ifdef VECT_TAB_RAM
  36. /* Set the Vector Table base location at 0x10000000 */
  37. SCB->VTOR = (0x10000000 & NVIC_VTOR_MASK);
  38. #else /* VECT_TAB_FLASH */
  39. /* Set the Vector Table base location at 0x00000000 */
  40. SCB->VTOR = (0x00000000 & NVIC_VTOR_MASK);
  41. #endif
  42. SystemCoreClockUpdate();
  43. /* init systick 1 systick = 1/(100M / 100) 100个systick = 1s*/
  44. SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND);
  45. /* set pend exception priority */
  46. NVIC_SetPriority(PendSV_IRQn, (1 << __NVIC_PRIO_BITS) - 1);
  47. /*init uart device*/
  48. rt_hw_uart_init();
  49. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  50. #ifdef RT_USING_COMPONENTS_INIT
  51. /* initialization board with RT-Thread Components */
  52. rt_components_board_init();
  53. #endif
  54. }
  55. /* initialization for system heap */
  56. int rt_hw_board_heap_init(void)
  57. {
  58. #ifdef RT_USING_HEAP
  59. rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
  60. #endif
  61. return 0;
  62. }
  63. void MemManage_Handler(void)
  64. {
  65. extern void HardFault_Handler(void);
  66. rt_kprintf("Memory Fault!\n");
  67. HardFault_Handler();
  68. }