board.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * File : board.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2009 RT-Thread Develop Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2009-01-05 Bernard first implementation
  13. * 2010-02-04 Magicoe ported to LPC17xx
  14. * 2010-05-02 Aozima update CMSIS to 130
  15. */
  16. #include <rthw.h>
  17. #include <rtthread.h>
  18. #include "board.h"
  19. #include "drv_uart.h"
  20. /**
  21. * This is the timer interrupt service routine.
  22. *
  23. */
  24. void SysTick_Handler(void)
  25. {
  26. /* enter interrupt */
  27. rt_interrupt_enter();
  28. rt_tick_increase();
  29. /* leave interrupt */
  30. rt_interrupt_leave();
  31. }
  32. /**
  33. * This function will initial LPC54xx board.
  34. */
  35. void rt_hw_board_init()
  36. {
  37. /* NVIC Configuration */
  38. #define NVIC_VTOR_MASK 0x3FFFFF80
  39. #ifdef VECT_TAB_RAM
  40. /* Set the Vector Table base location at 0x10000000 */
  41. SCB->VTOR = (0x10000000 & NVIC_VTOR_MASK);
  42. #else /* VECT_TAB_FLASH */
  43. /* Set the Vector Table base location at 0x00000000 */
  44. SCB->VTOR = (0x00000000 & NVIC_VTOR_MASK);
  45. #endif
  46. SystemCoreClockUpdate();
  47. /* init systick 1 systick = 1/(100M / 100) 100¸ösystick = 1s*/
  48. SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND);
  49. /* set pend exception priority */
  50. NVIC_SetPriority(PendSV_IRQn, (1 << __NVIC_PRIO_BITS) - 1);
  51. /*init uart device*/
  52. rt_hw_uart_init();
  53. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  54. #ifdef RT_USING_COMPONENTS_INIT
  55. /* initialization board with RT-Thread Components */
  56. rt_components_board_init();
  57. #endif
  58. }
  59. /* initialization for system heap */
  60. int rt_hw_board_heap_init(void)
  61. {
  62. #ifdef RT_USING_HEAP
  63. rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
  64. #endif
  65. return 0;
  66. }
  67. void MemManage_Handler(void)
  68. {
  69. extern void HardFault_Handler(void);
  70. rt_kprintf("Memory Fault!\n");
  71. HardFault_Handler();
  72. }