Clean up of the altered XPLAINBridge 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(TIMER1_COMPA_vect)
16 {
17 clock_datetime += 1;
18 }
19
20 //Initialise the clock
21 void clock_init()
22 {
23 OCR1A = ((F_CPU / 1024) / 100);
24 TCCR1A = (1 << WGM12);
25 TCCR1B = ((1 << CS12) | (1 << CS10));
26 TIMSK1 = (1 << OCIE1A);
27 }
28
29 //Return time
30 clock_time_t clock_time()
31 {
32 clock_time_t time;
33
34 cli();
35 time = clock_datetime;
36 sei();
37
38 return time;
39 }