X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/84e1241f8063dab6b82a580584fa11893a162b55..a9e0935a90346beb0c981924becc1f55d969a08b:/Projects/Webserver/Lib/uip/clock.c diff --git a/Projects/Webserver/Lib/uip/clock.c b/Projects/Webserver/Lib/uip/clock.c index e8a676b1a..450714888 100644 --- a/Projects/Webserver/Lib/uip/clock.c +++ b/Projects/Webserver/Lib/uip/clock.c @@ -1,37 +1,38 @@ -#include -#include -#include -#include -#include -#include - -#include "clock.h" - -//Counted time -volatile clock_time_t clock_datetime = 0; - -//Overflow interrupt -ISR(TIMER1_COMPA_vect) +#include +#include +#include +#include +#include +#include + +#include "clock.h" + +//Counted time +volatile clock_time_t clock_datetime = 0; + +//Overflow interrupt +ISR(TIMER1_COMPA_vect) { - clock_datetime += 1; -} - -//Initialise the clock + clock_datetime += 1; +} + +//Initialise the clock void clock_init() { - OCR1A = ((F_CPU / 1024) / 100); - TCCR1B = ((1 << WGM12) | (1 << CS12) | (1 << CS10)); - TIMSK1 = (1 << OCIE1A); -} - -//Return time + OCR1A = ((F_CPU / 1024) / 100); + TCCR1B = ((1 << WGM12) | (1 << CS12) | (1 << CS10)); + TIMSK1 = (1 << OCIE1A); +} + +//Return time clock_time_t clock_time() { - clock_time_t time; - - cli(); - time = clock_datetime; - sei(); - - return time; -} + clock_time_t time; + + ATOMIC_BLOCK(ATOMIC_FORCEON) + { + time = clock_datetime; + } + + return time; +}