Dependencies:   mbed

Revision:
0:adfbd02222d4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/R_Sw_Check.cpp	Mon Jun 13 15:20:17 2011 +0000
@@ -0,0 +1,69 @@
+/*****************************************************/
+/* Rotary Switch Check.cpp                           */
+/*                                                   */
+/*                                                   */
+/*****************************************************/
+
+#define  SW_CHECK_MAIN
+#include "R_Sw_Check.h"
+
+unsigned char ucRotarySwPol(char swA_0, char swB_0, 
+                            char swA_1, char swB_1,
+                            char swA_2, char swB_2,
+                            char swA_3, char swB_3,
+                            int *pol){
+
+    unsigned char ucRet = 0xFF;
+
+//  Rotary SW0
+    *pol = 0;
+    if((swA_0 == 0) && (g_sw0_0 == 1) && (swB_0 == 1)){
+        *pol = -1;
+        ucRet = 0;
+    }
+    if((swA_0 == 1) && (g_sw0_0 == 0) && (swB_0 == 1)){
+        *pol = 1;
+        ucRet = 0;
+    }
+    g_sw0_0 = swA_0;
+
+//  Rotary SW1
+    *(pol+1) = 0;
+    if((swA_1 == 0) && (g_sw1_0 == 1) && (swB_1 == 1)){
+        *(pol+1) = -1;
+        ucRet = 1;
+    }
+    if((swA_1 == 1) && (g_sw1_0 == 0) && (swB_1 == 1)){
+        *(pol+1) = 1;
+        ucRet = 1;
+    }
+    g_sw1_0 = swA_1;
+            
+//  Rotary SW2
+    *(pol+2) = 0;
+    if((swA_2 == 0) && (g_sw2_0 == 1) && (swB_2 == 1)){
+        *(pol+2) = -1;
+        ucRet = 2;
+    }
+    if((swA_2 == 1) && (g_sw2_0 == 0) && (swB_2 == 1)){
+        *(pol+2) = 1;
+        ucRet = 2;
+    }
+    g_sw2_0 = swA_2;
+
+//  Rotary SW3    
+    *(pol+3) = 0;
+    if((swA_3 == 0) && (g_sw3_0 == 1) && (swB_3 == 1)){
+        *(pol+3) = -1;
+        ucRet = 3;
+    }
+    if((swA_3 == 1) && (g_sw3_0 == 0) && (swB_3 == 1)){
+        *(pol+3) = 1;
+        ucRet = 3;
+    }
+    g_sw3_0 = swA_3;
+    
+    return ucRet;
+}
+
+#undef      SW_CHECK_MAIN
\ No newline at end of file