Subversion Repositories HomeAutomation

Rev

Rev 223 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

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