author | Tero Marttila <terom@paivola.fi> |
Thu, 03 Apr 2014 19:44:53 +0300 | |
changeset 52 | 237d1f5c1c32 |
parent 50 | e4ac5a591dcd |
child 53 | dfe67409fbcd |
permissions | -rw-r--r-- |
47
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
diff
changeset
|
1 |
#include <avr/io.h> |
49 | 2 |
|
52
237d1f5c1c32
hello: split out timer; add serial
Tero Marttila <terom@paivola.fi>
parents:
50
diff
changeset
|
3 |
#include "stdlib.h" |
237d1f5c1c32
hello: split out timer; add serial
Tero Marttila <terom@paivola.fi>
parents:
50
diff
changeset
|
4 |
#include "timer.c" // XXX |
237d1f5c1c32
hello: split out timer; add serial
Tero Marttila <terom@paivola.fi>
parents:
50
diff
changeset
|
5 |
#include "serial.c" // XXX |
47
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
diff
changeset
|
6 |
|
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
diff
changeset
|
7 |
int main (void) |
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
diff
changeset
|
8 |
{ |
49 | 9 |
timer_init(); |
52
237d1f5c1c32
hello: split out timer; add serial
Tero Marttila <terom@paivola.fi>
parents:
50
diff
changeset
|
10 |
serial_init(); |
49 | 11 |
|
47
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
diff
changeset
|
12 |
// LED |
49 | 13 |
sbi(&DDRB, DDB5); |
52
237d1f5c1c32
hello: split out timer; add serial
Tero Marttila <terom@paivola.fi>
parents:
50
diff
changeset
|
14 |
serial_enable(); |
49 | 15 |
|
16 |
sei(); |
|
17 |
||
18 |
// blink |
|
52
237d1f5c1c32
hello: split out timer; add serial
Tero Marttila <terom@paivola.fi>
parents:
50
diff
changeset
|
19 |
char c = 'X'; |
49 | 20 |
short timeout = 1000; |
21 |
short delta = 10; |
|
47
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
diff
changeset
|
22 |
|
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
diff
changeset
|
23 |
while (true) { |
52
237d1f5c1c32
hello: split out timer; add serial
Tero Marttila <terom@paivola.fi>
parents:
50
diff
changeset
|
24 |
serial_write(c); |
237d1f5c1c32
hello: split out timer; add serial
Tero Marttila <terom@paivola.fi>
parents:
50
diff
changeset
|
25 |
|
49 | 26 |
// bitflip |
27 |
xbi(&PORTB, PORTB5); |
|
47
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
diff
changeset
|
28 |
|
52
237d1f5c1c32
hello: split out timer; add serial
Tero Marttila <terom@paivola.fi>
parents:
50
diff
changeset
|
29 |
//timer_sleep(timeout); |
237d1f5c1c32
hello: split out timer; add serial
Tero Marttila <terom@paivola.fi>
parents:
50
diff
changeset
|
30 |
//timeout += delta; |
49 | 31 |
|
52
237d1f5c1c32
hello: split out timer; add serial
Tero Marttila <terom@paivola.fi>
parents:
50
diff
changeset
|
32 |
c = serial_read(); |
47
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
diff
changeset
|
33 |
} |
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
diff
changeset
|
34 |
} |