software: move time.c to libbase
authorSebastien Bourdeauducq <sebastien@milkymist.org>
Thu, 11 Jul 2013 17:00:48 +0000 (19:00 +0200)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Thu, 11 Jul 2013 17:00:48 +0000 (19:00 +0200)
software/include/base/time.h [new file with mode: 0644]
software/libbase/Makefile
software/libbase/time.c [new file with mode: 0644]
software/videomixer/Makefile
software/videomixer/dvisamplerX.c
software/videomixer/main.c
software/videomixer/time.c [deleted file]
software/videomixer/time.h [deleted file]

diff --git a/software/include/base/time.h b/software/include/base/time.h
new file mode 100644 (file)
index 0000000..3408390
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef __TIME_H
+#define __TIME_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void time_init(void);
+int elapsed(int *last_event, int period);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIME_H */
index e58da5cebb9238027f226031d0774216bb3a39e6..b9b9a7ab276d29c46bd06c66904f75f8abac3778 100644 (file)
@@ -1,7 +1,7 @@
 M2DIR=../..
 include $(M2DIR)/software/common.mak
 
-OBJECTS=setjmp.o libc.o errno.o crc16.o crc32.o console.o system.o id.o uart.o qsort.o strtod.o
+OBJECTS=setjmp.o libc.o errno.o crc16.o crc32.o console.o system.o id.o uart.o time.o qsort.o strtod.o
 
 all: crt0.o libbase.a libbase-nofloat.a
 
diff --git a/software/libbase/time.c b/software/libbase/time.c
new file mode 100644 (file)
index 0000000..c1c2ea8
--- /dev/null
@@ -0,0 +1,29 @@
+#include <hw/csr.h>
+#include <time.h>
+
+void time_init(void)
+{
+       int t;
+
+       timer0_en_write(0);
+       t = 2*identifier_frequency_read();
+       timer0_reload_write(t);
+       timer0_load_write(t);
+       timer0_en_write(1);
+}
+
+int elapsed(int *last_event, int period)
+{
+       int t, dt;
+
+       timer0_update_value_write(1);
+       t = timer0_reload_read() - timer0_value_read();
+       dt = t - *last_event;
+       if(dt < 0)
+               dt += timer0_reload_read();
+       if((dt > period) || (dt < 0)) {
+               *last_event = t;
+               return 1;
+       } else
+               return 0;
+}
index 347dccc7eebea74f88aeb7987882723e1be723e1..9742ac9d794a75eea7d4c2086cce4e896256ad5f 100644 (file)
@@ -1,7 +1,7 @@
 M2DIR=../..
 include $(M2DIR)/software/common.mak
 
-OBJECTS=isr.o time.o fb.o dvisampler0.o dvisampler1.o main.o
+OBJECTS=isr.o fb.o dvisampler0.o dvisampler1.o main.o
 
 all: videomixer.bin videomixer.fbi
 
index fbb0b688fe6f5e752f8922f03a623bd0b59d2253..e089ed195a4370d8ae341f86f3a5beedb94eee69 100644 (file)
@@ -3,10 +3,10 @@
 
 #include <irq.h>
 #include <uart.h>
+#include <time.h>
 #include <hw/csr.h>
 #include <hw/flags.h>
 
-#include "time.h"
 #include "fb.h"
 #include "dvisamplerX.h"
 
index 4407d64aafe2f51e2f2000c1c473012dab334686..5d6128a4e38f1e092ee3ff66ccbe6fdd34f90d39 100644 (file)
@@ -3,11 +3,11 @@
 
 #include <irq.h>
 #include <uart.h>
+#include <time.h>
 #include <hw/csr.h>
 #include <hw/flags.h>
 #include <console.h>
 
-#include "time.h"
 #include "fb.h"
 #include "dvisampler0.h"
 #include "dvisampler1.h"
diff --git a/software/videomixer/time.c b/software/videomixer/time.c
deleted file mode 100644 (file)
index 1f2c3aa..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#include <hw/csr.h>
-
-#include "time.h"
-
-void time_init(void)
-{
-       int t;
-
-       timer0_en_write(0);
-       t = 2*identifier_frequency_read();
-       timer0_reload_write(t);
-       timer0_load_write(t);
-       timer0_en_write(1);
-}
-
-int elapsed(int *last_event, int period)
-{
-       int t, dt;
-
-       timer0_update_value_write(1);
-       t = timer0_reload_read() - timer0_value_read();
-       dt = t - *last_event;
-       if(dt < 0)
-               dt += timer0_reload_read();
-       if((dt > period) || (dt < 0)) {
-               *last_event = t;
-               return 1;
-       } else
-               return 0;
-}
diff --git a/software/videomixer/time.h b/software/videomixer/time.h
deleted file mode 100644 (file)
index a8ebe23..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef __TIME_H
-#define __TIME_H
-
-void time_init(void);
-int elapsed(int *last_event, int period);
-
-#endif /* __TIME_H */