Subversion Repositories HomeAutomation

Rev

Details | Last modification | View Log | SVN | RSS feed

Rev Author Line No. Line
183 andfri 1
#include <inttypes.h>
223 andfri 2
#include <avr/interrupt.h>
183 andfri 3
#include <bios.h>
4
 
5
static int app_putchar(char c, FILE *stream);
6
static int app_getchar(FILE *stream);
7
 
8
static FILE mystdio = FDEV_SETUP_STREAM(app_putchar, app_getchar,
9
                                         _FDEV_SETUP_RW);
10
 
11
static int app_putchar(char c, FILE *stream) {
223 andfri 12
    bios->can_send(c);
13
    return 0;
183 andfri 14
}
15
 
16
static int app_getchar(FILE *stream) {
223 andfri 17
    return bios->can_receive();
183 andfri 18
}
19
 
20
int main(void)
21
{
223 andfri 22
    long time;
23
    long time1 = 0;
24
    long time2 = 0;
183 andfri 25
 
223 andfri 26
    sei();
27
 
183 andfri 28
    stdout = &mystdio;
29
    stdin = &mystdio;
30
 
31
    printf("AVR Test Application\n");
223 andfri 32
    printf("Using AVR BIOS version %x\n", bios->version);
183 andfri 33
 
223 andfri 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
    }
47
 
48
    return 0;
183 andfri 49
}