board.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2010-06-25 Bernard first version
  13. */
  14. #include <rtthread.h>
  15. #include <rthw.h>
  16. #include "board.h"
  17. #include "uart.h"
  18. #include <jz4755.h>
  19. /**
  20. * @addtogroup JZ47xx
  21. */
  22. /*@{*/
  23. /**
  24. * This is the timer interrupt service routine.
  25. */
  26. void rt_hw_timer_handler(int vector, void* param)
  27. {
  28. /* increase a OS tick */
  29. rt_tick_increase();
  30. /* clear flag */
  31. TCU_TFCR = TCU_TFCR_OSTFLAG;
  32. }
  33. /**
  34. * This function will initial OS timer
  35. */
  36. void rt_hw_timer_init(void)
  37. {
  38. rt_uint32_t val;
  39. /* disable TCU clock */
  40. CPM_CLKGR &= ~CPM_CLKGR_TCU;
  41. TCU_TECR = TCU_TECR_OSTCL;
  42. /* set */
  43. OST_DR = RT_TICK_PER_SECOND * 0xcffff;
  44. /* clear counter */
  45. OST_CNT = 0;
  46. #ifdef RTC_SRC_EXTAL
  47. OST_CSR = (val | OST_TCSR_EXT_EN);
  48. #else
  49. OST_CSR = (val | OST_TCSR_PCLK_EN);
  50. #endif
  51. TCU_TFCR = TCU_TFCR_OSTFLAG;
  52. TCU_TMCR = TCU_TMCR_OSTMCL;
  53. TCU_TESR = TCU_TESR_OSTST;
  54. rt_hw_interrupt_install(IRQ_TCU0, rt_hw_timer_handler, RT_NULL, "tick");
  55. rt_hw_interrupt_umask (IRQ_TCU0);
  56. }
  57. /**
  58. * This function will initial sam7s64 board.
  59. */
  60. void rt_hw_board_init()
  61. {
  62. #ifdef RT_USING_UART
  63. /* init hardware UART device */
  64. rt_hw_uart_init();
  65. #endif
  66. #ifdef RT_USING_CONSOLE
  67. /* set console device */
  68. rt_console_set_device("uart");
  69. #endif
  70. /* init operating system timer */
  71. rt_hw_timer_init();
  72. }
  73. /*@}*/