board.c 1.7 KB

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