Statistics
| Revision:

root / trunk / code / projects / scheduler / main.c @ 1574

History | View | Annotate | Download (695 Bytes)

1
#include <serial.h>
2
#include <avr/interrupt.h>
3
#include "scheduler.h"
4

    
5
void task0(void);
6
void task1(void);
7
void task2(void);
8

    
9
int main(void)
10
{
11
        //Granularity is currently seconds, 
12
        usb_init();
13

    
14
        usb_puts("Oh no!!! Reset!!\n\r");
15

    
16
        scheduler_init();
17
        register_task(task0, 48);
18
        register_task(task1, 20);
19
        register_task(task2, 80);
20

    
21
        while (1) {
22
                //usb_puti(time_now());
23
                usb_puts("main\n\r");
24
                delay_ms(20);
25
        }
26

    
27
        return 0;
28
}
29

    
30
void task0() { 
31
        int i = 0;
32
        while(1) { 
33
                usb_puts("Task 0-"); 
34
                usb_puti(i++);
35
                usb_puts("\n\r");
36
                delay_ms(20);
37
        }
38
}
39

    
40
void task1() { 
41
        cli();
42
        usb_puts("Hello from task 1\n\r");
43
        sei();
44
}
45

    
46
void task2() { 
47
        cli();
48
        usb_puts("Hello from task 2\n\r");
49
        sei();
50
}