summaryrefslogtreecommitdiff
path: root/cesar/hal/leon/test/timer
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/hal/leon/test/timer')
-rw-r--r--cesar/hal/leon/test/timer/Makefile11
-rw-r--r--cesar/hal/leon/test/timer/ecos.ecc.sh14
-rw-r--r--cesar/hal/leon/test/timer/src/target.c81
3 files changed, 106 insertions, 0 deletions
diff --git a/cesar/hal/leon/test/timer/Makefile b/cesar/hal/leon/test/timer/Makefile
new file mode 100644
index 0000000000..53cebb752f
--- /dev/null
+++ b/cesar/hal/leon/test/timer/Makefile
@@ -0,0 +1,11 @@
+BASE=../../..
+
+ECOS=y
+TARGET = sparc
+
+TARGET_PROGRAMS= test_leon_timer
+
+test_leon_timer_SOURCES = target.c
+test_leon_timer_MODULES = hal/leon lib
+
+include $(BASE)/common/make/top.mk
diff --git a/cesar/hal/leon/test/timer/ecos.ecc.sh b/cesar/hal/leon/test/timer/ecos.ecc.sh
new file mode 100644
index 0000000000..9307c8bcac
--- /dev/null
+++ b/cesar/hal/leon/test/timer/ecos.ecc.sh
@@ -0,0 +1,14 @@
+config=${1:-ecos-gen.ecc}
+ecosconfig --config=$config new sparc_leon default
+cat >> $config <<'EOF'
+cdl_component CYGPKG_HAL_SPARC_REGISTER_WINDOWS {
+ user_value 2
+}
+cdl_component CYGHWR_HAL_SPARC_FLAT {
+ user_value 1
+}
+cdl_option CYGBLD_GLOBAL_CFLAGS_PRE {
+ user_value "-mflat -Wall -Wpointer-arith -Wstrict-prototypes -Winline -Wundef -g -O2 -ffunction-sections -fdata-sections -fno-exceptions -fvtable-gc -finit-priority"
+}
+EOF
+ecosconfig --config=$config check
diff --git a/cesar/hal/leon/test/timer/src/target.c b/cesar/hal/leon/test/timer/src/target.c
new file mode 100644
index 0000000000..fa4939ac9f
--- /dev/null
+++ b/cesar/hal/leon/test/timer/src/target.c
@@ -0,0 +1,81 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file hal/leon/test/src/target.c
+ * \brief Test for leon timer 2 on target
+ * \ingroup hal/leon
+ *
+ */
+#include "common/std.h"
+
+#include <cyg/kernel/kapi.h>
+#include <cyg/hal/drv_api.h>
+#include <cyg/infra/diag.h>
+
+#include "hal/leon/timer.h"
+#include "hal/phy/phy.h"
+
+#include "lib/blk.h"
+
+bool test = false;
+leon_timer_t *leon_timer;
+phy_t *phy;
+
+static int my_thread_stack[512];
+static cyg_handle_t my_thread_handle;
+static cyg_thread my_thread_obj;
+
+void
+my_callback (void *toto)
+{
+ uint titi;
+
+ titi = 4;
+ titi /= 3;
+ test = true;
+
+ diag_write_string("TOTO computed\n");
+}
+
+void my_thread(cyg_addrword_t index)
+{
+ leon_timer_program (leon_timer, 0xFFFFFF);
+
+ while(!test)
+ {
+ diag_write_string("Wait the DSR\n\n");
+ leon_timer_uninit (leon_timer);
+ }
+
+
+ blk_release (phy);
+}
+
+int
+cyg_user_start (void)
+{
+ phy = blk_alloc ();
+ leon_timer = leon_timer_init (NULL, my_callback, phy);
+
+ // Thread Creation
+ cyg_thread_create(12, my_thread, (cyg_addrword_t) 0,
+ "My Thread", &my_thread_stack, 512,
+ &my_thread_handle, &my_thread_obj);
+
+ cyg_thread_resume(my_thread_handle);
+
+ diag_write_string("PGRM ended");
+ return 0;
+}
+
+u32
+phy_date(phy_t *phy)
+{
+ return 0;
+}
+