Rev 183 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 183 | Rev 223 | ||
|---|---|---|---|
| Line 1... | Line 1... | ||
| 1 | #include <inttypes.h> |
1 | #include <inttypes.h> |
| - | 2 | #include <avr/interrupt.h> |
|
| 2 | #include <bios.h> |
3 | #include <bios.h> |
| 3 | 4 | ||
| 4 | static int app_putchar(char c, FILE *stream); |
5 | static int app_putchar(char c, FILE *stream); |
| 5 | static int app_getchar(FILE *stream); |
6 | static int app_getchar(FILE *stream); |
| 6 | 7 | ||
| 7 | static FILE mystdio = FDEV_SETUP_STREAM(app_putchar, app_getchar, |
8 | static FILE mystdio = FDEV_SETUP_STREAM(app_putchar, app_getchar, |
| 8 | _FDEV_SETUP_RW); |
9 | _FDEV_SETUP_RW); |
| 9 | 10 | ||
| 10 | static int app_putchar(char c, FILE *stream) { |
11 | static int app_putchar(char c, FILE *stream) { |
| 11 |
|
12 | bios->can_send(c); |
| - | 13 | return 0; |
|
| 12 | } |
14 | } |
| 13 | 15 | ||
| 14 | static int app_getchar(FILE *stream) { |
16 | static int app_getchar(FILE *stream) { |
| 15 | return bios-> |
17 | return bios->can_receive(); |
| 16 | } |
18 | } |
| 17 | 19 | ||
| 18 | int main(void) |
20 | int main(void) |
| 19 | { |
21 | { |
| - | 22 | long time; |
|
| 20 |
|
23 | long time1 = 0; |
| 21 |
|
24 | long time2 = 0; |
| - | 25 | ||
| - | 26 | sei(); |
|
| 22 | 27 | ||
| 23 | stdout = &mystdio; |
28 | stdout = &mystdio; |
| 24 | stdin = &mystdio; |
29 | stdin = &mystdio; |
| 25 | 30 | ||
| 26 | printf("AVR Test Application\n"); |
31 | printf("AVR Test Application\n"); |
| 27 | printf("Using AVR BIOS version %x\n", |
32 | printf("Using AVR BIOS version %x\n", bios->version); |
| - | 33 | ||
| - | 34 | while (1) { |
|
| - | 35 | time = bios->timebase_get(); |
|
| - | 36 | if ((time - time1) >= 2000) { |
|
| - | 37 | time1 = time; |
|
| - | 38 | printf("Two seconds passed, time is now %d.\n", (int)time); |
|
| - | 39 | } |
|
| - | 40 | ||
| - | 41 | if ((time - time2) >= 20000) { |
|
| - | 42 | time2 = time; |
|
| - | 43 | printf("Will now hang node.\n"); |
|
| - | 44 | cli(); |
|
| - | 45 | } |
|
| - | 46 | } |
|
| 28 | 47 | ||
| 29 | return |
48 | return 0; |
| 30 | } |
49 | } |