board.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * File : board.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2009 - 2011 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. * 2011-02-24 Bernard first implementation
  13. */
  14. #include <rthw.h>
  15. #include <rtthread.h>
  16. #include "board.h"
  17. #include "mb9bf506r.h"
  18. #include "core_cm3.h"
  19. extern const uint32_t SystemFrequency;
  20. /**
  21. * @addtogroup FM3
  22. */
  23. /*@{*/
  24. /**
  25. * This is the timer interrupt service routine.
  26. *
  27. */
  28. void rt_hw_timer_handler(void)
  29. {
  30. /* enter interrupt */
  31. rt_interrupt_enter();
  32. rt_tick_increase();
  33. /* leave interrupt */
  34. rt_interrupt_leave();
  35. }
  36. void led_init(void)
  37. {
  38. /*Select CPIO function*/
  39. LED_PFR &= ~LED_MASK;
  40. /*Set Pin to turn off leds*/
  41. LED_PDOR |= LED_MASK;
  42. /*Make led pins outputs*/
  43. LED_DDR |= LED_MASK;
  44. }
  45. void rt_hw_led_on(int n)
  46. {
  47. switch(n)
  48. {
  49. case LED1:
  50. LED_PDOR &= ~LED1;
  51. break;
  52. case LED2:
  53. LED_PDOR &= ~LED2;
  54. break;
  55. case LED3:
  56. LED_PDOR &= ~LED3;
  57. break;
  58. default:
  59. break;
  60. }
  61. }
  62. void rt_hw_led_off(int n)
  63. {
  64. switch(n)
  65. {
  66. case LED1:
  67. LED_PDOR |= LED1;
  68. break;
  69. case LED2:
  70. LED_PDOR |= LED2;
  71. break;
  72. case LED3:
  73. LED_PDOR |= LED3;
  74. break;
  75. default:
  76. break;
  77. }
  78. }
  79. /**
  80. * This function will initial FM3 Easy Kit board.
  81. */
  82. void rt_hw_board_init()
  83. {
  84. led_init();
  85. /* init systick */
  86. SysTick_Config(SystemFrequency/RT_TICK_PER_SECOND - 1);
  87. }
  88. /*@}*/