replace the hostapd preselection with a wpad preselection to enable proper client...
[openwrt.git] / target / linux / at91 / image / dfboot / src / led.c
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 <AT91RM9200.h>
26
27 #define GREEN_LED AT91C_PIO_PB0
28 #define YELLOW_LED AT91C_PIO_PB1
29 #define RED_LED AT91C_PIO_PB2
30
31 void LED_set(unsigned int led)
32 {
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
36 }
37
38 void green_LED_on(void)
39 {
40 AT91PS_PIO PIOB = AT91C_BASE_PIOB;
41 // PIOB->PIO_CODR = GREEN_LED;
42 PIOB->PIO_CODR = (1 << 0);
43 }
44
45 void yellow_LED_on(void)
46 {
47 AT91PS_PIO PIOB = AT91C_BASE_PIOB;
48 // PIOB->PIO_CODR = YELLOW_LED;
49 PIOB->PIO_CODR = (1 << 1);
50 }
51
52 void red_LED_on(void)
53 {
54 AT91PS_PIO PIOB = AT91C_BASE_PIOB;
55 // PIOB->PIO_CODR = RED_LED;
56 PIOB->PIO_CODR = (1 << 2);
57 }
58
59 void green_LED_off(void)
60 {
61 AT91PS_PIO PIOB = AT91C_BASE_PIOB;
62 // PIOB->PIO_SODR = GREEN_LED;
63 PIOB->PIO_SODR = (1 << 0);
64 }
65
66 void yellow_LED_off(void)
67 {
68 AT91PS_PIO PIOB = AT91C_BASE_PIOB;
69 // PIOB->PIO_SODR = YELLOW_LED;
70 PIOB->PIO_SODR = (1 << 1);
71 }
72
73 void red_LED_off(void)
74 {
75 AT91PS_PIO PIOB = AT91C_BASE_PIOB;
76 // PIOB->PIO_SODR = RED_LED;
77 PIOB->PIO_SODR = (1 << 2);
78 }
79
80 void LED_blink(unsigned int led)
81 {
82 volatile int i,j;
83 for(i = 0; i < 5; i++) {
84 LED_set((1 << led)&0x7);
85 for(j= 0; j < 200000; j++);
86 LED_set(0);
87 for(j= 0; j < 200000; j++);
88 }
89 }
90
91
92 void LED_init (void)
93 {
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;
101 // Turn all LEDs OFF
102 PIOB->PIO_SODR = AT91C_PIO_PB2 | AT91C_PIO_PB1 | AT91C_PIO_PB0;
103 }
This page took 0.051572 seconds and 5 git commands to generate.