]> rtime.felk.cvut.cz Git - eurobot/public.git/commitdiff
Added pwmtest application
authorsojka <sojka@78ed6b52-5822-0410-8084-884f26da6e90>
Thu, 29 Mar 2007 08:09:08 +0000 (08:09 +0000)
committersojka <sojka@78ed6b52-5822-0410-8084-884f26da6e90>
Thu, 29 Mar 2007 08:09:08 +0000 (08:09 +0000)
git-svn-id: svn+ssh://rtime.felk.cvut.cz/var/svn/eurobot/trunk/soft@135 78ed6b52-5822-0410-8084-884f26da6e90

app/pwmtest/Makefile [new file with mode: 0644]
app/pwmtest/Makefile.omk [new file with mode: 0644]
app/pwmtest/pwmtest.c [new file with mode: 0644]
build/h8eurobot/pwmtest [new symlink]

diff --git a/app/pwmtest/Makefile b/app/pwmtest/Makefile
new file mode 100644 (file)
index 0000000..f595272
--- /dev/null
@@ -0,0 +1,14 @@
+# Generic directory or leaf node makefile for OCERA make framework
+
+ifndef MAKERULES_DIR
+MAKERULES_DIR := $(shell ( old_pwd="" ;  while [ ! -e Makefile.rules ] ; do if [ "$$old_pwd" == `pwd`  ] ; then exit 1 ; else old_pwd=`pwd` ; cd -L .. 2>/dev/null ; fi ; done ; pwd ) )
+endif
+
+ifeq ($(MAKERULES_DIR),)
+all : default
+.DEFAULT::
+       @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+else   
+include $(MAKERULES_DIR)/Makefile.rules
+endif
+
diff --git a/app/pwmtest/Makefile.omk b/app/pwmtest/Makefile.omk
new file mode 100644 (file)
index 0000000..0840441
--- /dev/null
@@ -0,0 +1,6 @@
+# -*- makefile -*-
+
+bin_PROGRAMS = pwmtest
+
+pwmtest_SOURCES = pwmtest.c
+pwmtest_LIBS = boot_fn
diff --git a/app/pwmtest/pwmtest.c b/app/pwmtest/pwmtest.c
new file mode 100644 (file)
index 0000000..32f4a1d
--- /dev/null
@@ -0,0 +1,34 @@
+#include <stdio.h>
+#include <h8s2638h.h>
+#include <system_def.h>
+#include <boot_fn.h>
+
+int main()
+{
+    DEB_LED_INIT(); /* Init port with LEDs */
+
+    *SYS_MSTPCRD&=~MSTPCRD_PWMm;
+
+    *PWM_PWOCR2 =
+        PWOCR2_OE2Am | PWOCR2_OE2Bm | PWOCR2_OE2Cm |
+        PWOCR2_OE2Em | PWOCR2_OE2Fm | PWOCR2_OE2Gm;    // switch on needed channels
+               
+    unsigned cyr = CPU_SYS_HZ/20000; /* PWM freq */
+    if (cyr & PWBFR2A_DTxm) cyr = PWBFR2A_DTxm;
+    *PWM_PWCYR2 = cyr;
+
+    *PWM_PWCR2 = PWCR2_CSTm | PWCR2_CKS_F1; /* Start PWM timer, clock = phi/1 */
+
+    int i;
+    while (1) {
+        for (i=0; i<cyr; i++) {
+            *DIO_PEDR = (i>>3)&0xf;
+            *PWM_PWBFR2A = i;
+            *PWM_PWBFR2B = i;
+            *PWM_PWBFR2C = i;
+            FlWait(1000);
+        }
+    }
+
+    return 0;
+}
diff --git a/build/h8eurobot/pwmtest b/build/h8eurobot/pwmtest
new file mode 120000 (symlink)
index 0000000..13586eb
--- /dev/null
@@ -0,0 +1 @@
+../../app/pwmtest
\ No newline at end of file