board.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright (c) 2006-2018, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2008-12-11 xuxinming first version
  9. */
  10. #include <rtthread.h>
  11. #include <rthw.h>
  12. #include <LPC24xx.h>
  13. #include "board.h"
  14. #define DATA_COUNT 14400000/RT_TICK_PER_SECOND /* T0MR0 = delayInMs * (Fpclk / 1000); */
  15. extern void rt_hw_serial_init(void);
  16. /**
  17. * @addtogroup LPC2478
  18. */
  19. /*@{*/
  20. void rt_timer_handler(int vector, void* param)
  21. {
  22. T0IR |= 0x01; /* clear interrupt flag */
  23. rt_tick_increase();
  24. VICVectAddr = 0; /* Acknowledge Interrupt */
  25. }
  26. /**
  27. * This function will init LPC2478 board
  28. */
  29. void rt_hw_board_init(void)
  30. {
  31. #if defined(RT_USING_DEVICE) && defined(RT_USING_UART1)
  32. rt_hw_serial_init();
  33. rt_console_set_device("uart1");
  34. #endif
  35. T0IR = 0xff;
  36. T0TC = 0;
  37. T0MCR = 0x03;
  38. T0MR0 = (DATA_COUNT);
  39. rt_hw_interrupt_install(TIMER0_INT, rt_timer_handler, RT_NULL, "tick");
  40. rt_hw_interrupt_umask(TIMER0_INT);
  41. T0TCR = 0x01; //enable timer0 counter
  42. }
  43. /*@}*/