board.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * File : board.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006, 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://openlab.rt-thread.com/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2008-12-11 xuxinming first version
  13. */
  14. #include <rtthread.h>
  15. #include <rthw.h>
  16. #include <LPC24xx.h>
  17. #include "board.h"
  18. #define DATA_COUNT 14400000/RT_TICK_PER_SECOND /* T0MR0 = delayInMs * (Fpclk / 1000); */
  19. extern void rt_hw_serial_init(void);
  20. /**
  21. * @addtogroup LPC2478
  22. */
  23. /*@{*/
  24. void rt_timer_handler(int vector, void* param)
  25. {
  26. T0IR |= 0x01; /* clear interrupt flag */
  27. rt_tick_increase();
  28. VICVectAddr = 0; /* Acknowledge Interrupt */
  29. }
  30. /**
  31. * This function will init LPC2478 board
  32. */
  33. void rt_hw_board_init(void)
  34. {
  35. #if defined(RT_USING_DEVICE) && defined(RT_USING_UART1)
  36. rt_hw_serial_init();
  37. rt_console_set_device("uart1");
  38. #endif
  39. T0IR = 0xff;
  40. T0TC = 0;
  41. T0MCR = 0x03;
  42. T0MR0 = (DATA_COUNT);
  43. rt_hw_interrupt_install(TIMER0_INT, rt_timer_handler, RT_NULL, "tick");
  44. rt_hw_interrupt_umask(TIMER0_INT);
  45. T0TCR = 0x01; //enable timer0 counter
  46. }
  47. /*@}*/