OSDN Git Service

Moved the interrupt handler registering function to bfin_util.
[bluetank/bluetank.git] / firm / bare_metal / common / rotenc.c
index 09cf26c..39e0b03 100644 (file)
@@ -38,6 +38,7 @@
 #include <builtins.h>
 #include <sys/exception.h>
 #include "rotenc.h"
+#include "bfin_util.h"
 
 /*
  * PA : PF6
@@ -45,7 +46,7 @@
  * SW : PF10
  */
 
-/* \e$B%7%9%F%`%/%m%C%/\e(B(100MHz) */
+/* System clock frequency : 100MHz */
 #define SCLOCK_HZ   (100000000)
 
 #define INIT_PORT() \
 ROTENC_CALLBACK callback = NULL;
 void *user_obj = NULL;
 
-typedef __attribute__((interrupt_handler)) void (*ex_handler_fn_gcc)(void);
-
 static __attribute__((interrupt_handler)) void rotenc_isr(void)
 {
-    /* \e$B3d$j9~$_%9%F!<%?%9$N99?7\e(B */
+    /* Update the interrupt status */
     *pTIMER_STATUS = TIMIL1;
     ssync();
 
@@ -90,19 +89,6 @@ static __attribute__((interrupt_handler)) void rotenc_isr(void)
     }
 }
 
-/* Visual DSP++\e$B$N\e(Bregister_handler\e$B4X?t<BAu\e(B */
-static void vdsp_register_handler(interrupt_kind kind, ex_handler_fn_gcc fn)
-{
-    uint32_t l_mask;
-
-    if((ik_emulation > kind) || (kind > ik_ivg15)) return;
-
-    *((ex_handler_fn_gcc*)&(((uint32_t*)EVT0)[(int32_t)kind])) = fn;
-    l_mask  = cli();
-    l_mask |= 1u << (int32_t)kind;
-    sti(l_mask);
-}
-
 void rotenc_init(ROTENC_CALLBACK func, void *extobj)
 {
     INIT_PORT();
@@ -110,12 +96,12 @@ void rotenc_init(ROTENC_CALLBACK func, void *extobj)
     callback = func;
     user_obj = extobj;
 
-    /* \e$B3d$j9~$_%O%s%I%i$r\e(BIVG11\e$B$KEPO?\e(B */
-    vdsp_register_handler(ik_ivg11, rotenc_isr);
+    /* Register interrupt handler to IVG11 */
+    bfin_util_register_handler(ik_ivg11, rotenc_isr);
     *pSIC_IMASK |= IRQ_TIMER1;
 
-    /* GP\e$B%?%$%^\e(B1\e$B$N@_Dj\e(B */
-    /* 1ms\e$BC10L$K3d$j9~$_$,$+$+$k$h$&$K@_Dj\e(B */
+    /* Setup GP Timer 1 */
+    /* 1ms/event */
     *pTIMER1_CONFIG = OUT_DIS | IRQ_ENA | PERIOD_CNT | PWM_OUT;
     *pTIMER1_PERIOD = SCLOCK_HZ / 1000;
     *pTIMER1_WIDTH = 1;