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