summaryrefslogtreecommitdiff
path: root/cesar/hal/leon/test/timer/src/target.c
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/hal/leon/test/timer/src/target.c')
-rw-r--r--cesar/hal/leon/test/timer/src/target.c81
1 files changed, 81 insertions, 0 deletions
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;
+}
+