Peter Pearse | dcbfd2e | 2007-08-14 10:14:05 +0100 | [diff] [blame] | 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 | |
| 25 | #include <common.h> |
| 26 | #include <asm/arch/AT91RM9200.h> |
| 27 | |
| 28 | #define GREEN_LED AT91C_PIO_PB0 |
| 29 | #define YELLOW_LED AT91C_PIO_PB1 |
| 30 | #define RED_LED AT91C_PIO_PB2 |
| 31 | |
| 32 | void green_LED_on(void) |
| 33 | { |
| 34 | AT91PS_PIO PIOB = AT91C_BASE_PIOB; |
| 35 | PIOB->PIO_CODR = GREEN_LED; |
| 36 | } |
| 37 | |
| 38 | void yellow_LED_on(void) |
| 39 | { |
| 40 | AT91PS_PIO PIOB = AT91C_BASE_PIOB; |
| 41 | PIOB->PIO_CODR = YELLOW_LED; |
| 42 | } |
| 43 | |
| 44 | void red_LED_on(void) |
| 45 | { |
| 46 | AT91PS_PIO PIOB = AT91C_BASE_PIOB; |
| 47 | PIOB->PIO_CODR = RED_LED; |
| 48 | } |
| 49 | |
| 50 | void green_LED_off(void) |
| 51 | { |
| 52 | AT91PS_PIO PIOB = AT91C_BASE_PIOB; |
| 53 | PIOB->PIO_SODR = GREEN_LED; |
| 54 | } |
| 55 | |
| 56 | void yellow_LED_off(void) |
| 57 | { |
| 58 | AT91PS_PIO PIOB = AT91C_BASE_PIOB; |
| 59 | PIOB->PIO_SODR = YELLOW_LED; |
| 60 | } |
| 61 | |
| 62 | void red_LED_off(void) |
| 63 | { |
| 64 | AT91PS_PIO PIOB = AT91C_BASE_PIOB; |
| 65 | PIOB->PIO_SODR = RED_LED; |
| 66 | } |
| 67 | |
| 68 | |
| 69 | void LED_init (void) |
| 70 | { |
| 71 | AT91PS_PIO PIOB = AT91C_BASE_PIOB; |
| 72 | AT91PS_PMC PMC = AT91C_BASE_PMC; |
| 73 | PMC->PMC_PCER = (1 << AT91C_ID_PIOB); /* Enable PIOB clock */ |
| 74 | /* Disable peripherals on LEDs */ |
| 75 | PIOB->PIO_PER = AT91C_PIO_PB2 | AT91C_PIO_PB1 | AT91C_PIO_PB0; |
| 76 | /* Enable pins as outputs */ |
| 77 | PIOB->PIO_OER = AT91C_PIO_PB2 | AT91C_PIO_PB1 | AT91C_PIO_PB0; |
| 78 | /* Turn all LEDs OFF */ |
| 79 | PIOB->PIO_SODR = AT91C_PIO_PB2 | AT91C_PIO_PB1 | AT91C_PIO_PB0; |
| 80 | } |