-
Notifications
You must be signed in to change notification settings - Fork 1
/
mf-tester.c
68 lines (53 loc) · 1.02 KB
/
mf-tester.c
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
#include <avr/eeprom.h>
#include <avr/io.h>
#include <util/delay.h>
uint8_t state;
int main() {
state = eeprom_read_byte((uint8_t*)0) & 1;
if ((MCUSR & (1 << PORF)) != 0) {
MCUSR = 1;
state ^= 1;
eeprom_write_byte((uint8_t*)0, state);
}
DDRB |= _BV(DDB0);
DDRB |= _BV(DDB1);
DDRB |= _BV(DDB2);
DDRB |= _BV(DDB3);
DDRB |= _BV(DDB4);
while (1) {
if (state == 1) {
PORTB ^= _BV(PB4);
_delay_ms(500);
PORTB ^= _BV(PB4);
PORTB ^= _BV(PB3);
_delay_ms(500);
PORTB ^= _BV(PB3);
PORTB ^= _BV(PB2);
_delay_ms(500);
PORTB ^= _BV(PB2);
PORTB ^= _BV(PB1);
_delay_ms(500);
PORTB ^= _BV(PB1);
PORTB ^= _BV(PB0);
_delay_ms(500);
PORTB ^= _BV(PB0);
}
else {
PORTB ^= _BV(PB0);
_delay_ms(500);
PORTB ^= _BV(PB0);
PORTB ^= _BV(PB1);
_delay_ms(500);
PORTB ^= _BV(PB1);
PORTB ^= _BV(PB2);
_delay_ms(500);
PORTB ^= _BV(PB2);
PORTB ^= _BV(PB3);
_delay_ms(500);
PORTB ^= _BV(PB3);
PORTB ^= _BV(PB4);
_delay_ms(500);
PORTB ^= _BV(PB4);
}
}
}