board.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 "uart.h"
  19. #include "board.h"
  20. #include "LPC17xx.h"
  21. /**
  22. * @addtogroup LPC17xx
  23. */
  24. /*@{*/
  25. /**
  26. * This is the timer interrupt service routine.
  27. *
  28. */
  29. void rt_hw_timer_handler(void)
  30. {
  31. /* enter interrupt */
  32. rt_interrupt_enter();
  33. rt_tick_increase();
  34. /* leave interrupt */
  35. rt_interrupt_leave();
  36. }
  37. void SysTick_Handler(void)
  38. {
  39. rt_hw_timer_handler();
  40. }
  41. /**
  42. * This function will initial LPC17xx board.
  43. */
  44. void rt_hw_board_init()
  45. {
  46. /* NVIC Configuration */
  47. #define NVIC_VTOR_MASK 0x3FFFFF80
  48. #ifdef VECT_TAB_RAM
  49. /* Set the Vector Table base location at 0x10000000 */
  50. SCB->VTOR = (0x10000000 & NVIC_VTOR_MASK);
  51. #else /* VECT_TAB_FLASH */
  52. /* Set the Vector Table base location at 0x00000000 */
  53. SCB->VTOR = (0x00000000 & NVIC_VTOR_MASK);
  54. #endif
  55. /* initialize systick */
  56. SysTick_Config( SystemCoreClock/RT_TICK_PER_SECOND);
  57. /* set pend exception priority */
  58. NVIC_SetPriority(PendSV_IRQn, (1<<__NVIC_PRIO_BITS) - 1);
  59. #ifdef RT_USING_UART0
  60. rt_hw_uart_init();
  61. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  62. #endif
  63. }
  64. /*@}*/