Started Webserver RNDIS host project.
[pub/USBasp.git] / Projects / Incomplete / Webserver / Lib / uip / conf / clock-arch.c
1 #include "global-conf.h"
2 #include <stdint.h>
3 #include <stdlib.h>
4 #include <stdio.h>
5 #include <avr/interrupt.h>
6 #include <avr/io.h>
7 #include <avr/sfr_defs.h>
8
9 #include "clock-arch.h"
10
11 //Counted time
12 volatile clock_time_t clock_datetime = 0;
13
14 //Overflow interrupt
15 ISR(TIMER0_OVF_vect)
16 {
17 clock_datetime += 1;
18 }
19
20 //Initialise the clock
21 void clock_init()
22 {
23 //Activate overflow interrupt for timer0
24 TIMSK0 |= (1<<TOIE0);
25
26 //Use prescaler 1024
27 TCCR0B |= ((1<<CS12)|(1<<CS10));
28
29 //Activate interrupts
30 sei();
31 }
32
33 //Return time
34 clock_time_t clock_time()
35 {
36 clock_time_t time;
37
38 cli();
39 time = clock_datetime;
40 sei();
41
42 return time;
43 }