led.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * File : led.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. * 2011-01-13 weety first version
  13. */
  14. #include <rtthread.h>
  15. #include <at91sam926x.h>
  16. #include "led.h"
  17. void led_init(void)
  18. {
  19. at91_sys_write(AT91_PIOC, (1<<8)|(1<<11)|(1<<6));
  20. at91_sys_write(AT91_PIOC+0x10, (1<<8)|(1<<11)|(1<<6));
  21. at91_sys_write(AT91_PIOC+0x64, (1<<8)|(1<<11)|(1<<6));
  22. at91_sys_write(AT91_PIOC+0x30, (1<<8)|(1<<11)|(1<<6));
  23. }
  24. void led_on(int num)
  25. {
  26. switch(num)
  27. {
  28. case 1:
  29. at91_sys_write(AT91_PIOC+0x34, 1<<8);
  30. break;
  31. case 2:
  32. at91_sys_write(AT91_PIOC+0x34, 1<<11);
  33. break;
  34. case 3:
  35. at91_sys_write(AT91_PIOC+0x34, 1<<6);
  36. break;
  37. default:
  38. break;
  39. }
  40. }
  41. void led_off(int num)
  42. {
  43. switch(num)
  44. {
  45. case 1:
  46. at91_sys_write(AT91_PIOC+0x30, 1<<8);
  47. break;
  48. case 2:
  49. at91_sys_write(AT91_PIOC+0x30, 1<<11);
  50. break;
  51. case 3:
  52. at91_sys_write(AT91_PIOC+0x30, 1<<6);
  53. break;
  54. default:
  55. break;
  56. }
  57. //at91_sys_write(AT91_PIOC+0x30, 1<<8);
  58. }