led.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. #include <asm/io.h>
  27. #define GREEN_LED AT91C_PIO_PB0
  28. #define YELLOW_LED AT91C_PIO_PB1
  29. #define RED_LED AT91C_PIO_PB2
  30. void green_LED_on(void)
  31. {
  32. AT91PS_PIO PIOB = AT91C_BASE_PIOB;
  33. writel(GREEN_LED, PIOB->PIO_CODR);
  34. }
  35. void yellow_LED_on(void)
  36. {
  37. AT91PS_PIO PIOB = AT91C_BASE_PIOB;
  38. writel(YELLOW_LED, PIOB->PIO_CODR);
  39. }
  40. void red_LED_on(void)
  41. {
  42. AT91PS_PIO PIOB = AT91C_BASE_PIOB;
  43. writel(RED_LED, PIOB->PIO_CODR);
  44. }
  45. void green_LED_off(void)
  46. {
  47. AT91PS_PIO PIOB = AT91C_BASE_PIOB;
  48. writel(GREEN_LED, PIOB->PIO_SODR);
  49. }
  50. void yellow_LED_off(void)
  51. {
  52. AT91PS_PIO PIOB = AT91C_BASE_PIOB;
  53. writel(YELLOW_LED, PIOB->PIO_SODR);
  54. }
  55. void red_LED_off(void)
  56. {
  57. AT91PS_PIO PIOB = AT91C_BASE_PIOB;
  58. writel(RED_LED, PIOB->PIO_SODR);
  59. }
  60. void coloured_LED_init (void)
  61. {
  62. AT91PS_PIO PIOB = AT91C_BASE_PIOB;
  63. AT91PS_PMC PMC = AT91C_BASE_PMC;
  64. /* Enable PIOB clock */
  65. writel((1 << AT91C_ID_PIOB), PMC->PMC_PCER);
  66. /* Disable peripherals on LEDs */
  67. writel(AT91C_PIO_PB2 | AT91C_PIO_PB1 | AT91C_PIO_PB0, PIOB->PIO_PER);
  68. /* Enable pins as outputs */
  69. writel(AT91C_PIO_PB2 | AT91C_PIO_PB1 | AT91C_PIO_PB0, PIOB->PIO_OER);
  70. /* Turn all LEDs OFF */
  71. writel(AT91C_PIO_PB2 | AT91C_PIO_PB1 | AT91C_PIO_PB0, PIOB->PIO_SODR);
  72. }