Subversion Repositories HomeAutomation

Rev

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

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