diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2010-02-02 12:51:05 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2010-02-02 12:51:05 +0000 |
commit | 84e1241f8063dab6b82a580584fa11893a162b55 (patch) | |
tree | 22c4f596fcfc35d689d3a5665f1602db9fc66261 /Projects/Webserver/Lib/uip/clock.c | |
parent | 1008260985a50df686bb6c0b73c6a0b10fd24b2b (diff) | |
download | lufa-84e1241f8063dab6b82a580584fa11893a162b55.tar.gz lufa-84e1241f8063dab6b82a580584fa11893a162b55.tar.bz2 lufa-84e1241f8063dab6b82a580584fa11893a162b55.zip |
Replace the Webserver demo's uIP with the latest code ripped from the Contiki project by Adam Dunkels.
Diffstat (limited to 'Projects/Webserver/Lib/uip/clock.c')
-rw-r--r-- | Projects/Webserver/Lib/uip/clock.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/Projects/Webserver/Lib/uip/clock.c b/Projects/Webserver/Lib/uip/clock.c new file mode 100644 index 000000000..e8a676b1a --- /dev/null +++ b/Projects/Webserver/Lib/uip/clock.c @@ -0,0 +1,37 @@ +#include <stdint.h> +#include <stdlib.h> +#include <stdio.h> +#include <avr/interrupt.h> +#include <avr/io.h> +#include <avr/sfr_defs.h> + +#include "clock.h" + +//Counted time +volatile clock_time_t clock_datetime = 0; + +//Overflow interrupt +ISR(TIMER1_COMPA_vect) +{
+ 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 +clock_time_t clock_time()
+{
+ clock_time_t time; + + cli(); + time = clock_datetime; + sei(); + + return time; +} |