00001 #include "swmux.h" 00002 00003 #ifdef CONF_DSENSOR 00004 #ifdef CONF_DSENSOR_SWMUX 00005 00006 00007 //sampled multiplexor ranges 00008 00009 //0xFE00 - sampled raw value for no sensors touched 00010 #define SWMUX_0000_S 0xF000 00011 #define SWMUX_0000_E 0xFFFF 00012 00013 //0x9640 - sampled raw value for only A touched 00014 #define SWMUX_A000_S 0x9000 00015 #define SWMUX_A000_E 0x9FFF 00016 00017 //Ox8180 - sampled raw value for A and B touched 00018 #define SWMUX_AB00_S 0x8000 00019 #define SWMUX_AB00_E 0x8BFF 00020 00021 //0x8D80 - sampled raw value for A and C touched 00022 #define SWMUX_A0C0_S 0x8C00 00023 #define SWMUX_A0C0_E 0x8FFF 00024 00025 //Ox7800 - sampled raw value for A, B, and C touched 00026 #define SWMUX_ABC0_S 0x7000 00027 #define SWMUX_ABC0_E 0x7FFF 00028 00029 //0xC000 - sampled raw value for only B touched 00030 #define SWMUX_0B00_S 0xBFF0 00031 #define SWMUX_0B00_E 0xC5FF 00032 00033 //0xA6C0 - sampled raw value for B and C touched 00034 #define SWMUX_0BC0_S 0xA000 00035 #define SWMUX_0BC0_E 0xAFFF 00036 00037 //OxD6C0 - sampled raw value for only C touched 00038 #define SWMUX_00C0_S 0xD000 00039 #define SWMUX_00C0_E 0xDFFF 00040 00041 //exta sensor D, when pressed A,B,C are masked out 00042 //0x0600 00043 #define SWMUX_XXXD_S 0x0000 00044 #define SWMUX_XXXD_E 0x4FFF 00045 00046 00047 00048 unsigned char swmux_bits(unsigned int raw) { 00049 if(raw>=SWMUX_0000_S && raw <=SWMUX_0000_E) { 00050 return 0; 00051 } else if (raw>=SWMUX_A000_S && raw <=SWMUX_A000_E) { 00052 return SWMUX_A_MASK; 00053 } else if (raw>=SWMUX_AB00_S && raw <=SWMUX_AB00_E) { 00054 return SWMUX_A_MASK|SWMUX_B_MASK; 00055 } else if (raw>=SWMUX_A0C0_S && raw <=SWMUX_A0C0_E) { 00056 return SWMUX_A_MASK|SWMUX_C_MASK; 00057 } else if (raw>=SWMUX_ABC0_S && raw <=SWMUX_ABC0_E) { 00058 return SWMUX_A_MASK|SWMUX_B_MASK|SWMUX_C_MASK; 00059 } else if (raw>=SWMUX_0B00_S && raw <=SWMUX_0B00_E) { 00060 return SWMUX_B_MASK; 00061 } else if (raw>=SWMUX_0BC0_S && raw <=SWMUX_0BC0_E) { 00062 return SWMUX_B_MASK|SWMUX_C_MASK; 00063 } else if (raw>=SWMUX_00C0_S && raw <=SWMUX_00C0_E) { 00064 return SWMUX_C_MASK; 00065 } else if (raw>=SWMUX_XXXD_S && raw <=SWMUX_XXXD_E) { 00066 return SWMUX_D_MASK; 00067 } else { 00068 return SWMUX_ERROR_MASK; 00069 } 00070 }//endof swmux_val 00071 00072 #endif //CONF_DSENSOR_SWMUX 00073 #endif //CONF_DSENSOR 00074
brickOS is released under the
Mozilla Public License.
Original code copyright 1998-2002 by the authors. |