3 * Atmel Nordic AB <www.atmel.com>
4 * Ulf Samuelsson <ulf@atmel.com>
6 * See file CREDITS for list of people who contributed to this
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.
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.
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,
25 #include <AT91RM9200.h>
27 #define GREEN_LED AT91C_PIO_PB0
28 #define YELLOW_LED AT91C_PIO_PB1
29 #define RED_LED AT91C_PIO_PB2
31 void LED_set(unsigned int led
)
33 AT91PS_PIO PIOB
= AT91C_BASE_PIOB
;
34 PIOB
->PIO_SODR
= (led
^ 0x7) & 0x7; // All 0's => Set PIO high => OFF
35 PIOB
->PIO_CODR
= led
& 0x7; // All 1's => Set PIO low => ON
38 void green_LED_on(void)
40 AT91PS_PIO PIOB
= AT91C_BASE_PIOB
;
41 // PIOB->PIO_CODR = GREEN_LED;
42 PIOB
->PIO_CODR
= (1 << 0);
45 void yellow_LED_on(void)
47 AT91PS_PIO PIOB
= AT91C_BASE_PIOB
;
48 // PIOB->PIO_CODR = YELLOW_LED;
49 PIOB
->PIO_CODR
= (1 << 1);
54 AT91PS_PIO PIOB
= AT91C_BASE_PIOB
;
55 // PIOB->PIO_CODR = RED_LED;
56 PIOB
->PIO_CODR
= (1 << 2);
59 void green_LED_off(void)
61 AT91PS_PIO PIOB
= AT91C_BASE_PIOB
;
62 // PIOB->PIO_SODR = GREEN_LED;
63 PIOB
->PIO_SODR
= (1 << 0);
66 void yellow_LED_off(void)
68 AT91PS_PIO PIOB
= AT91C_BASE_PIOB
;
69 // PIOB->PIO_SODR = YELLOW_LED;
70 PIOB
->PIO_SODR
= (1 << 1);
73 void red_LED_off(void)
75 AT91PS_PIO PIOB
= AT91C_BASE_PIOB
;
76 // PIOB->PIO_SODR = RED_LED;
77 PIOB
->PIO_SODR
= (1 << 2);
80 void LED_blink(unsigned int led
)
83 for(i
= 0; i
< 5; i
++) {
84 LED_set((1 << led
)&0x7);
85 for(j
= 0; j
< 200000; j
++);
87 for(j
= 0; j
< 200000; j
++);
94 AT91PS_PIO PIOB
= AT91C_BASE_PIOB
;
95 AT91PS_PMC PMC
= AT91C_BASE_PMC
;
96 PMC
->PMC_PCER
= (1 << AT91C_ID_PIOB
); // Enable PIOB clock
97 // Disable peripherals on LEDs
98 PIOB
->PIO_PER
= AT91C_PIO_PB2
| AT91C_PIO_PB1
| AT91C_PIO_PB0
;
99 // Enable pins as outputs
100 PIOB
->PIO_OER
= AT91C_PIO_PB2
| AT91C_PIO_PB1
| AT91C_PIO_PB0
;
102 PIOB
->PIO_SODR
= AT91C_PIO_PB2
| AT91C_PIO_PB1
| AT91C_PIO_PB0
;
This page took 0.051229 seconds and 5 git commands to generate.