led.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * (C) Copyright 2006
  3. * Atmel Nordic AB <www.atmel.com>
  4. * Ulf Samuelsson <ulf@atmel.com>
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. */
  24. #include <common.h>
  25. #include <asm/arch/AT91RM9200.h>
  26. #define GREEN_LED AT91C_PIO_PB0
  27. #define YELLOW_LED AT91C_PIO_PB1
  28. #define RED_LED AT91C_PIO_PB2
  29. void green_LED_on(void)
  30. {
  31. AT91PS_PIO PIOB = AT91C_BASE_PIOB;
  32. PIOB->PIO_CODR = GREEN_LED;
  33. }
  34. void yellow_LED_on(void)
  35. {
  36. AT91PS_PIO PIOB = AT91C_BASE_PIOB;
  37. PIOB->PIO_CODR = YELLOW_LED;
  38. }
  39. void red_LED_on(void)
  40. {
  41. AT91PS_PIO PIOB = AT91C_BASE_PIOB;
  42. PIOB->PIO_CODR = RED_LED;
  43. }
  44. void green_LED_off(void)
  45. {
  46. AT91PS_PIO PIOB = AT91C_BASE_PIOB;
  47. PIOB->PIO_SODR = GREEN_LED;
  48. }
  49. void yellow_LED_off(void)
  50. {
  51. AT91PS_PIO PIOB = AT91C_BASE_PIOB;
  52. PIOB->PIO_SODR = YELLOW_LED;
  53. }
  54. void red_LED_off(void)
  55. {
  56. AT91PS_PIO PIOB = AT91C_BASE_PIOB;
  57. PIOB->PIO_SODR = RED_LED;
  58. }
  59. void coloured_LED_init (void)
  60. {
  61. AT91PS_PIO PIOB = AT91C_BASE_PIOB;
  62. AT91PS_PMC PMC = AT91C_BASE_PMC;
  63. PMC->PMC_PCER = (1 << AT91C_ID_PIOB); /* Enable PIOB clock */
  64. /* Disable peripherals on LEDs */
  65. PIOB->PIO_PER = AT91C_PIO_PB2 | AT91C_PIO_PB1 | AT91C_PIO_PB0;
  66. /* Enable pins as outputs */
  67. PIOB->PIO_OER = AT91C_PIO_PB2 | AT91C_PIO_PB1 | AT91C_PIO_PB0;
  68. /* Turn all LEDs OFF */
  69. PIOB->PIO_SODR = AT91C_PIO_PB2 | AT91C_PIO_PB1 | AT91C_PIO_PB0;
  70. }