fb11e647
vrobic
reseau statique a...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
/*
* Copyright (C) 2016 Freie Universitรคt Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser General
* Public License v2.1. See the file LICENSE in the top level directory for more
* details.
*/
/**
* @ingroup tests
* @{
*
* @file
* @brief Test for the on-board LED macros
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
*
* @}
*/
#include <stdio.h>
#include "board.h"
#include "periph_conf.h"
#ifdef CLOCK_CORECLOCK
#define DELAY_SHORT (CLOCK_CORECLOCK / 50)
#else
#define DELAY_SHORT (500000UL)
#endif
#define DELAY_LONG (DELAY_SHORT * 4)
void dumb_delay(uint32_t delay)
{
for (uint32_t i = 0; i < delay; i++) {
__asm__("nop");
}
}
int main(void)
{
int numof = 0;
/* get the number of available LED's and turn them all off*/
#ifdef LED0_ON
++numof;
LED0_OFF;
#endif
#ifdef LED1_ON
++numof;
LED1_OFF;
#endif
#ifdef LED2_ON
++numof;
LED2_OFF;
#endif
#ifdef LED3_ON
++numof;
LED3_OFF;
#endif
#ifdef LED4_ON
++numof;
LED4_OFF;
#endif
#ifdef LED5_ON
++numof;
LED5_OFF;
#endif
#ifdef LED6_ON
++numof;
LED6_OFF;
#endif
#ifdef LED7_ON
++numof;
LED7_OFF;
#endif
puts("On-board LED test\n");
if (numof == 0) {
puts("NO LEDs AVAILABLE");
}
else {
printf("Available LEDs: %i\n\n", numof);
puts("Will now light up each LED once short and twice long in a loop");
}
while (1) {
#ifdef LED0_ON
LED0_ON;
dumb_delay(DELAY_LONG);
LED0_OFF;
dumb_delay(DELAY_LONG);
LED0_TOGGLE;
dumb_delay(DELAY_SHORT);
LED0_TOGGLE;
dumb_delay(DELAY_SHORT);
LED0_TOGGLE;
dumb_delay(DELAY_SHORT);
LED0_TOGGLE;
dumb_delay(DELAY_LONG);
#endif
#ifdef LED1_ON
LED1_ON;
dumb_delay(DELAY_LONG);
LED1_OFF;
dumb_delay(DELAY_LONG);
LED1_TOGGLE;
dumb_delay(DELAY_SHORT);
LED1_TOGGLE;
dumb_delay(DELAY_SHORT);
LED1_TOGGLE;
dumb_delay(DELAY_SHORT);
LED1_TOGGLE;
dumb_delay(DELAY_LONG);
#endif
#ifdef LED2_ON
LED2_ON;
dumb_delay(DELAY_LONG);
LED2_OFF;
dumb_delay(DELAY_LONG);
LED2_TOGGLE;
dumb_delay(DELAY_SHORT);
LED2_TOGGLE;
dumb_delay(DELAY_SHORT);
LED2_TOGGLE;
dumb_delay(DELAY_SHORT);
LED2_TOGGLE;
dumb_delay(DELAY_LONG);
#endif
#ifdef LED3_ON
LED3_ON;
dumb_delay(DELAY_LONG);
LED3_OFF;
dumb_delay(DELAY_LONG);
LED3_TOGGLE;
dumb_delay(DELAY_SHORT);
LED3_TOGGLE;
dumb_delay(DELAY_SHORT);
LED3_TOGGLE;
dumb_delay(DELAY_SHORT);
LED3_TOGGLE;
dumb_delay(DELAY_LONG);
#endif
#ifdef LED4_ON
LED4_ON;
dumb_delay(DELAY_LONG);
LED4_OFF;
dumb_delay(DELAY_LONG);
LED4_TOGGLE;
dumb_delay(DELAY_SHORT);
LED4_TOGGLE;
dumb_delay(DELAY_SHORT);
LED4_TOGGLE;
dumb_delay(DELAY_SHORT);
LED4_TOGGLE;
dumb_delay(DELAY_LONG);
#endif
#ifdef LED5_ON
LED5_ON;
dumb_delay(DELAY_LONG);
LED5_OFF;
dumb_delay(DELAY_LONG);
LED5_TOGGLE;
dumb_delay(DELAY_SHORT);
LED5_TOGGLE;
dumb_delay(DELAY_SHORT);
LED5_TOGGLE;
dumb_delay(DELAY_SHORT);
LED5_TOGGLE;
dumb_delay(DELAY_LONG);
#endif
#ifdef LED6_ON
LED6_ON;
dumb_delay(DELAY_LONG);
LED6_OFF;
dumb_delay(DELAY_LONG);
LED6_TOGGLE;
dumb_delay(DELAY_SHORT);
LED6_TOGGLE;
dumb_delay(DELAY_SHORT);
LED6_TOGGLE;
dumb_delay(DELAY_SHORT);
LED6_TOGGLE;
dumb_delay(DELAY_LONG);
#endif
#ifdef LED7_ON
LED7_ON;
dumb_delay(DELAY_LONG);
LED7_OFF;
dumb_delay(DELAY_LONG);
LED7_TOGGLE;
dumb_delay(DELAY_SHORT);
LED7_TOGGLE;
dumb_delay(DELAY_SHORT);
LED7_TOGGLE;
dumb_delay(DELAY_SHORT);
LED7_TOGGLE;
dumb_delay(DELAY_LONG);
#endif
}
return 0;
}
|