]> rtime.felk.cvut.cz Git - sysless.git/blob - arch/arm/mach-at91sam7/libs/ledshow/ledshow.c
Build framework for the AT91SAM7 architecture
[sysless.git] / arch / arm / mach-at91sam7 / libs / ledshow / ledshow.c
1 /*
2  * ledshow.c
3  *
4  * An open implementation of Profibus DP functionalities.
5  * Led show routines.
6  *
7  * Copyright (c) 2009 Tran Duy Khanh. All rights reserved.
8  *
9  * This program is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU General Public License as published by the
11  * Free Software Foundation; either version 2, or (at your option) any
12  * later version.
13  *
14  * This program is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * General Public License for more details.
18  *
19  * Project homepage:
20  *
21  *      http://www.pbmaster.org
22  *      http://pbmaster.sourceforge.net
23  *
24  * Contact information:
25  *
26  *      Tran Duy Khanh  <tran@pbmaster.org>
27  *                      <trandk1@users.sourceforge.net>
28  */
29
30 #include "ledshow.h"
31
32 void led_show1(struct ledshow *ls)
33 {
34         unsigned char i;
35
36         ls->pattern = 0x01;
37         ls->set(ls->pattern);
38
39         for (i=0; i<ls->led_cnt; i++) {
40                 ls->set(ls->pattern);
41                 ls->pattern = ls->pattern << 1;
42                 ls->wait(1);
43         }
44
45         for (i=0; i<ls->led_cnt; i++) {
46                 ls->set((0x01 << (ls->led_cnt-1)));
47                 ls->wait(1);
48                 ls->set(0x0);
49                 ls->wait(1);
50         }
51
52         ls->pattern = (0x01 << (ls->led_cnt-1));
53         for (i=0; i<ls->led_cnt; i++) {
54                 ls->set(ls->pattern);
55                 ls->pattern = ls->pattern >> 1;
56                 ls->wait(1);
57         }
58
59         for (i=0; i<ls->led_cnt; i++) {
60                 ls->set(0x01);
61                 ls->wait(1);
62                 ls->set(0x0);
63                 ls->wait(1);
64         }
65 }
66
67 void led_show2(struct ledshow *ls)
68 {
69         unsigned char i;
70
71         ls->pattern = 0x01;
72         ls->set(ls->pattern);
73
74         for (i=0; i<ls->led_cnt; i++) {
75                 ls->set(ls->pattern);
76                 ls->pattern = (ls->pattern << 1) | 0x01;
77                 ls->wait(2);
78         }
79
80         ls->pattern = (0x01 << (ls->led_cnt-1));
81         for (i=0; i<ls->led_cnt; i++) {
82                 ls->set(ls->pattern);
83                 ls->pattern = (ls->pattern >> 1) | (0x01 << (ls->led_cnt-1));
84                 ls->wait(2);
85         }
86 }
87
88 void led_show3(struct ledshow *ls)
89 {
90         unsigned char i;
91
92         for (i=0; i<ls->led_cnt; i++) {
93                 ls->set(0x99);
94                 ls->wait(1);
95                 ls->set(0x0);
96                 ls->wait(1);
97         }
98
99         for (i=0; i<ls->led_cnt; i++) {
100                 ls->set(0x66);
101                 ls->wait(1);
102                 ls->set(0x0);
103                 ls->wait(1);
104         }
105 }
106
107 void led_show4(struct ledshow *ls)
108 {
109         unsigned char i;
110
111         ls->pattern = 0x01;
112         ls->set(ls->pattern);
113         for (i=0; i<ls->led_cnt; i++) {
114                 ls->set(ls->pattern);
115                 ls->pattern = ls->pattern << 1;
116                 ls->wait(1);
117         }
118
119         ls->pattern = (0x01 << (ls->led_cnt-1));
120         for (i=0; i<ls->led_cnt; i++) {
121                 ls->set(ls->pattern);
122                 ls->pattern = ls->pattern >> 1;
123                 ls->wait(1);
124         }
125 }
126
127 void led_show5(struct ledshow *ls)
128 {
129         unsigned char i;
130
131         ls->pattern=0x1;
132         ls->set(ls->pattern);
133
134         for (i=0; i<ls->led_cnt; i++) {
135                 ls->set(ls->pattern);
136                 ls->pattern = (ls->pattern << 1) | 0x01;
137                 ls->wait(2);
138         }
139
140         ls->pattern = 0xff;
141         for (i=0; i<ls->led_cnt; i++) {
142                 ls->set(ls->pattern);
143                 ls->pattern = (ls->pattern << 1);
144                 ls->wait(1);
145         }
146
147         ls->pattern = 0x00;
148         ls->set(ls->pattern);
149
150         for (i=0; i<ls->led_cnt; i++) {
151                 ls->set(ls->pattern);
152                 ls->pattern = (ls->pattern >> 1) | (0x01 << (ls->led_cnt-1));
153                 ls->wait(2);
154         }
155
156         ls->pattern = 0xff;
157         for (i=0; i<ls->led_cnt; i++) {
158                 ls->set(ls->pattern);
159                 ls->pattern = (ls->pattern >> 1);
160                 ls->wait(1);
161         }
162 }
163
164 void led_show6(struct ledshow *ls)
165 {
166         ls->set(0x55);
167         ls->wait(3);
168         ls->set(0xaa);
169         ls->wait(3);
170 }
171
172 void led_show7(struct ledshow *ls)
173 {
174         ls->set(0x99);
175         ls->wait(2);
176         ls->set(0x66);
177         ls->wait(2);
178 }
179
180 void led_show8(struct ledshow *ls)
181 {
182         unsigned char i;
183
184         for (i=0; i<6; i++) {
185                 ls->set(0xcc);
186                 ls->wait(1);
187                 ls->set(0x00);
188                 ls->wait(1);
189         }
190
191         for (i=0; i<6; i++) {
192                 ls->set(0x33);
193                 ls->wait(1);
194                 ls->set(0x00);
195                 ls->wait(1);
196         }
197 }