![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
R_Sw_Check.cpp@0:8e3468376286, 2011-05-07 (annotated)
- Committer:
- faker
- Date:
- Sat May 07 12:37:10 2011 +0000
- Revision:
- 0:8e3468376286
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
faker | 0:8e3468376286 | 1 | /*****************************************************/ |
faker | 0:8e3468376286 | 2 | /* Rotary Switch Check.cpp */ |
faker | 0:8e3468376286 | 3 | /* */ |
faker | 0:8e3468376286 | 4 | /* */ |
faker | 0:8e3468376286 | 5 | /*****************************************************/ |
faker | 0:8e3468376286 | 6 | |
faker | 0:8e3468376286 | 7 | #define SW_CHECK_MAIN |
faker | 0:8e3468376286 | 8 | #include "R_Sw_Check.h" |
faker | 0:8e3468376286 | 9 | |
faker | 0:8e3468376286 | 10 | unsigned char ucRotarySwPol(char swA_0, char swB_0, |
faker | 0:8e3468376286 | 11 | char swA_1, char swB_1, |
faker | 0:8e3468376286 | 12 | char swA_2, char swB_2, |
faker | 0:8e3468376286 | 13 | char swA_3, char swB_3, |
faker | 0:8e3468376286 | 14 | int *pol){ |
faker | 0:8e3468376286 | 15 | |
faker | 0:8e3468376286 | 16 | unsigned char ucRet = 0xFF; |
faker | 0:8e3468376286 | 17 | |
faker | 0:8e3468376286 | 18 | // Rotary SW0 |
faker | 0:8e3468376286 | 19 | *pol = 0; |
faker | 0:8e3468376286 | 20 | if((swA_0 == 0) && (g_sw0_0 == 1) && (swB_0 == 1)){ |
faker | 0:8e3468376286 | 21 | *pol = -1; |
faker | 0:8e3468376286 | 22 | ucRet = 0; |
faker | 0:8e3468376286 | 23 | } |
faker | 0:8e3468376286 | 24 | if((swA_0 == 1) && (g_sw0_0 == 0) && (swB_0 == 1)){ |
faker | 0:8e3468376286 | 25 | *pol = 1; |
faker | 0:8e3468376286 | 26 | ucRet = 0; |
faker | 0:8e3468376286 | 27 | } |
faker | 0:8e3468376286 | 28 | g_sw0_0 = swA_0; |
faker | 0:8e3468376286 | 29 | |
faker | 0:8e3468376286 | 30 | // Rotary SW1 |
faker | 0:8e3468376286 | 31 | *(pol+1) = 0; |
faker | 0:8e3468376286 | 32 | if((swA_1 == 0) && (g_sw1_0 == 1) && (swB_1 == 1)){ |
faker | 0:8e3468376286 | 33 | *(pol+1) = -1; |
faker | 0:8e3468376286 | 34 | ucRet = 1; |
faker | 0:8e3468376286 | 35 | } |
faker | 0:8e3468376286 | 36 | if((swA_1 == 1) && (g_sw1_0 == 0) && (swB_1 == 1)){ |
faker | 0:8e3468376286 | 37 | *(pol+1) = 1; |
faker | 0:8e3468376286 | 38 | ucRet = 1; |
faker | 0:8e3468376286 | 39 | } |
faker | 0:8e3468376286 | 40 | g_sw1_0 = swA_1; |
faker | 0:8e3468376286 | 41 | |
faker | 0:8e3468376286 | 42 | // Rotary SW2 |
faker | 0:8e3468376286 | 43 | *(pol+2) = 0; |
faker | 0:8e3468376286 | 44 | if((swA_2 == 0) && (g_sw2_0 == 1) && (swB_2 == 1)){ |
faker | 0:8e3468376286 | 45 | *(pol+2) = -1; |
faker | 0:8e3468376286 | 46 | ucRet = 2; |
faker | 0:8e3468376286 | 47 | } |
faker | 0:8e3468376286 | 48 | if((swA_2 == 1) && (g_sw2_0 == 0) && (swB_2 == 1)){ |
faker | 0:8e3468376286 | 49 | *(pol+2) = 1; |
faker | 0:8e3468376286 | 50 | ucRet = 2; |
faker | 0:8e3468376286 | 51 | } |
faker | 0:8e3468376286 | 52 | g_sw2_0 = swA_2; |
faker | 0:8e3468376286 | 53 | |
faker | 0:8e3468376286 | 54 | // Rotary SW3 |
faker | 0:8e3468376286 | 55 | *(pol+3) = 0; |
faker | 0:8e3468376286 | 56 | if((swA_3 == 0) && (g_sw3_0 == 1) && (swB_3 == 1)){ |
faker | 0:8e3468376286 | 57 | *(pol+3) = -1; |
faker | 0:8e3468376286 | 58 | ucRet = 3; |
faker | 0:8e3468376286 | 59 | } |
faker | 0:8e3468376286 | 60 | if((swA_3 == 1) && (g_sw3_0 == 0) && (swB_3 == 1)){ |
faker | 0:8e3468376286 | 61 | *(pol+3) = 1; |
faker | 0:8e3468376286 | 62 | ucRet = 3; |
faker | 0:8e3468376286 | 63 | } |
faker | 0:8e3468376286 | 64 | g_sw3_0 = swA_3; |
faker | 0:8e3468376286 | 65 | |
faker | 0:8e3468376286 | 66 | return ucRet; |
faker | 0:8e3468376286 | 67 | } |
faker | 0:8e3468376286 | 68 | |
faker | 0:8e3468376286 | 69 | #undef SW_CHECK_MAIN |