led.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * File : led.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006, RT-Thread Develop Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2011-01-13 weety first version
  23. */
  24. #include <rtthread.h>
  25. #include <at91sam926x.h>
  26. #include "led.h"
  27. #if 1
  28. // GB9260 board
  29. #define PIO_LED AT91_PIOB
  30. #define LED1 (1 << 25) // LED_SYS
  31. #define LED2 (0)
  32. #define LED3 (1 << 23) // LED_USR
  33. #define LED_ALL (LED1 | LED2 | LED3)
  34. #else
  35. #define PIO_LED AT91_PIOC
  36. #define LED1 (1 << 8)
  37. #define LED2 (1 << 11)
  38. #define LED3 (1 << 6)
  39. #define LED_ALL (LED1 | LED2 | LED3)
  40. #endif
  41. void led_init(void)
  42. {
  43. at91_sys_write(PIO_LED+0x00, LED_ALL);
  44. at91_sys_write(PIO_LED+0x10, LED_ALL);
  45. at91_sys_write(PIO_LED+0x64, LED_ALL);
  46. at91_sys_write(PIO_LED+0x30, LED_ALL);
  47. }
  48. void led_on(int num)
  49. {
  50. switch(num)
  51. {
  52. case 1:
  53. at91_sys_write(PIO_LED+0x34, LED1);
  54. break;
  55. case 2:
  56. at91_sys_write(PIO_LED+0x34, LED2);
  57. break;
  58. case 3:
  59. at91_sys_write(PIO_LED+0x34, LED3);
  60. break;
  61. default:
  62. break;
  63. }
  64. }
  65. void led_off(int num)
  66. {
  67. switch(num)
  68. {
  69. case 1:
  70. at91_sys_write(PIO_LED+0x30, LED1);
  71. break;
  72. case 2:
  73. at91_sys_write(PIO_LED+0x30, LED2);
  74. break;
  75. case 3:
  76. at91_sys_write(PIO_LED+0x30, LED3);
  77. break;
  78. default:
  79. break;
  80. }
  81. }