board.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * File : board.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2014 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. * 2014-06-20 xiaonong ported to LPC43xx
  14. */
  15. #include <rthw.h>
  16. #include <rtthread.h>
  17. #include "board.h"
  18. #include "drv_uart.h"
  19. /**
  20. * This is the timer interrupt service routine.
  21. *
  22. */
  23. void SysTick_Handler(void)
  24. {
  25. /* enter interrupt */
  26. rt_interrupt_enter();
  27. rt_tick_increase();
  28. /* leave interrupt */
  29. rt_interrupt_leave();
  30. }
  31. extern void SystemCoreClockUpdate(void);
  32. /**
  33. * This function will initial LPC43xx board.
  34. */
  35. void rt_hw_board_init()
  36. {
  37. #ifdef CORE_M4
  38. /* NVIC Configuration */
  39. #define NVIC_VTOR_MASK 0x3FFFFF80
  40. #ifdef VECT_TAB_RAM
  41. /* Set the Vector Table base location at 0x10000000 */
  42. SCB->VTOR = (0x10000000 & NVIC_VTOR_MASK);
  43. #else /* VECT_TAB_FLASH */
  44. /* Set the Vector Table base location at 0x00000000 */
  45. SCB->VTOR = (0x00000000 & NVIC_VTOR_MASK);
  46. #endif
  47. #endif
  48. /* update the core clock */
  49. SystemCoreClockUpdate();
  50. /* init systick */
  51. SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND);
  52. /* set pend exception priority */
  53. NVIC_SetPriority(PendSV_IRQn, (1 << __NVIC_PRIO_BITS) - 1);
  54. /* init uart device */
  55. rt_hw_uart_init();
  56. /* setup the console device */
  57. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  58. #if LPC_EXT_SDRAM == 1
  59. lpc_sdram_hw_init();
  60. mpu_init();
  61. #endif
  62. }