MINI8I8O5A
mini8i8o5a.h@1:cf9f7638d5e9, 2015-10-13 (annotated)
- Committer:
- tsuparit
- Date:
- Tue Oct 13 10:26:26 2015 +0000
- Revision:
- 1:cf9f7638d5e9
- Parent:
- 0:d111e9801c2c
update Share variable with input sampling filter
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tsuparit | 0:d111e9801c2c | 1 | #define ON 1 |
tsuparit | 0:d111e9801c2c | 2 | #define OFF 0 |
tsuparit | 0:d111e9801c2c | 3 | |
tsuparit | 0:d111e9801c2c | 4 | |
tsuparit | 0:d111e9801c2c | 5 | AnalogIn ain0(A0); |
tsuparit | 0:d111e9801c2c | 6 | AnalogIn ain1(A1); |
tsuparit | 0:d111e9801c2c | 7 | AnalogIn ain2(A2); |
tsuparit | 0:d111e9801c2c | 8 | AnalogIn ain3(A3); |
tsuparit | 0:d111e9801c2c | 9 | AnalogIn ain4(A4); |
tsuparit | 0:d111e9801c2c | 10 | AnalogIn ain5(A5); |
tsuparit | 0:d111e9801c2c | 11 | |
tsuparit | 0:d111e9801c2c | 12 | DigitalOut OUT7(PTE5); |
tsuparit | 0:d111e9801c2c | 13 | DigitalOut OUT6(PTE4); |
tsuparit | 0:d111e9801c2c | 14 | DigitalOut OUT5(PTE3); |
tsuparit | 0:d111e9801c2c | 15 | DigitalOut OUT4(PTE2); |
tsuparit | 0:d111e9801c2c | 16 | |
tsuparit | 0:d111e9801c2c | 17 | DigitalOut OUT0(PTB11); |
tsuparit | 0:d111e9801c2c | 18 | DigitalOut OUT3(PTB10); |
tsuparit | 0:d111e9801c2c | 19 | DigitalOut OUT2(PTC12); |
tsuparit | 0:d111e9801c2c | 20 | DigitalOut OUT1(PTC13); |
tsuparit | 0:d111e9801c2c | 21 | |
tsuparit | 0:d111e9801c2c | 22 | |
tsuparit | 0:d111e9801c2c | 23 | DigitalIn IN7(PTE20); |
tsuparit | 0:d111e9801c2c | 24 | DigitalIn IN6(PTE21); |
tsuparit | 0:d111e9801c2c | 25 | DigitalIn IN5(PTE29); |
tsuparit | 0:d111e9801c2c | 26 | DigitalIn IN4(PTC5); |
tsuparit | 0:d111e9801c2c | 27 | DigitalIn IN3(PTC4); |
tsuparit | 0:d111e9801c2c | 28 | DigitalIn IN2(PTC3); |
tsuparit | 0:d111e9801c2c | 29 | DigitalIn IN0(PTC7); |
tsuparit | 0:d111e9801c2c | 30 | DigitalIn IN1(PTC0); |
tsuparit | 0:d111e9801c2c | 31 | |
tsuparit | 1:cf9f7638d5e9 | 32 | DigitalOut BUZZER(PTB8); |
tsuparit | 1:cf9f7638d5e9 | 33 | |
tsuparit | 1:cf9f7638d5e9 | 34 | #define updateinputbuffer Input_sampling(512) |
tsuparit | 1:cf9f7638d5e9 | 35 | |
tsuparit | 1:cf9f7638d5e9 | 36 | unsigned char INPUT,IN[8],OUTPUT; |
tsuparit | 1:cf9f7638d5e9 | 37 | |
tsuparit | 1:cf9f7638d5e9 | 38 | void Input_sampling(unsigned int testloop) |
tsuparit | 1:cf9f7638d5e9 | 39 | { |
tsuparit | 1:cf9f7638d5e9 | 40 | //default Input_sampling(512) |
tsuparit | 1:cf9f7638d5e9 | 41 | int i; |
tsuparit | 1:cf9f7638d5e9 | 42 | if (testloop<16) testloop=16; |
tsuparit | 1:cf9f7638d5e9 | 43 | |
tsuparit | 1:cf9f7638d5e9 | 44 | unsigned int Inbuf0=0; |
tsuparit | 1:cf9f7638d5e9 | 45 | unsigned int Inbuf1=0; |
tsuparit | 1:cf9f7638d5e9 | 46 | unsigned int Inbuf2=0; |
tsuparit | 1:cf9f7638d5e9 | 47 | unsigned int Inbuf3=0; |
tsuparit | 1:cf9f7638d5e9 | 48 | unsigned int Inbuf4=0; |
tsuparit | 1:cf9f7638d5e9 | 49 | unsigned int Inbuf5=0; |
tsuparit | 1:cf9f7638d5e9 | 50 | unsigned int Inbuf6=0; |
tsuparit | 1:cf9f7638d5e9 | 51 | unsigned int Inbuf7=0; |
tsuparit | 1:cf9f7638d5e9 | 52 | /* |
tsuparit | 1:cf9f7638d5e9 | 53 | Inbuf0=0; |
tsuparit | 1:cf9f7638d5e9 | 54 | Inbuf1=0; |
tsuparit | 1:cf9f7638d5e9 | 55 | Inbuf2=0; |
tsuparit | 1:cf9f7638d5e9 | 56 | Inbuf3=0; |
tsuparit | 1:cf9f7638d5e9 | 57 | Inbuf4=0; |
tsuparit | 1:cf9f7638d5e9 | 58 | Inbuf5=0; |
tsuparit | 1:cf9f7638d5e9 | 59 | Inbuf6=0; |
tsuparit | 1:cf9f7638d5e9 | 60 | Inbuf7=0; |
tsuparit | 1:cf9f7638d5e9 | 61 | */ |
tsuparit | 1:cf9f7638d5e9 | 62 | for (i=0;i<=testloop;i++) |
tsuparit | 1:cf9f7638d5e9 | 63 | { |
tsuparit | 1:cf9f7638d5e9 | 64 | if (IN0==0) Inbuf0++; |
tsuparit | 1:cf9f7638d5e9 | 65 | if (IN1==0) Inbuf1++; |
tsuparit | 1:cf9f7638d5e9 | 66 | if (IN2==0) Inbuf2++; |
tsuparit | 1:cf9f7638d5e9 | 67 | if (IN3==0) Inbuf3++; |
tsuparit | 1:cf9f7638d5e9 | 68 | if (IN4==0) Inbuf4++; |
tsuparit | 1:cf9f7638d5e9 | 69 | if (IN5==0) Inbuf5++; |
tsuparit | 1:cf9f7638d5e9 | 70 | if (IN6==0) Inbuf6++; |
tsuparit | 1:cf9f7638d5e9 | 71 | if (IN7==0) Inbuf7++; |
tsuparit | 1:cf9f7638d5e9 | 72 | |
tsuparit | 1:cf9f7638d5e9 | 73 | } |
tsuparit | 1:cf9f7638d5e9 | 74 | #define INACTIVELIMIT (testloop*3/4) |
tsuparit | 1:cf9f7638d5e9 | 75 | for (i=0;i<=7;i++) IN[i]=0; |
tsuparit | 1:cf9f7638d5e9 | 76 | if (Inbuf0> INACTIVELIMIT ) IN[0]=1; |
tsuparit | 1:cf9f7638d5e9 | 77 | if (Inbuf1> INACTIVELIMIT ) IN[1]=2; |
tsuparit | 1:cf9f7638d5e9 | 78 | if (Inbuf2> INACTIVELIMIT ) IN[2]=4; |
tsuparit | 1:cf9f7638d5e9 | 79 | if (Inbuf3> INACTIVELIMIT ) IN[3]=8; |
tsuparit | 1:cf9f7638d5e9 | 80 | if (Inbuf4> INACTIVELIMIT ) IN[4]=16; |
tsuparit | 1:cf9f7638d5e9 | 81 | if (Inbuf5> INACTIVELIMIT ) IN[5]=32; |
tsuparit | 1:cf9f7638d5e9 | 82 | if (Inbuf6> INACTIVELIMIT ) IN[6]=64; |
tsuparit | 1:cf9f7638d5e9 | 83 | if (Inbuf7> INACTIVELIMIT ) IN[7]=128; |
tsuparit | 1:cf9f7638d5e9 | 84 | |
tsuparit | 1:cf9f7638d5e9 | 85 | |
tsuparit | 1:cf9f7638d5e9 | 86 | INPUT=0; |
tsuparit | 1:cf9f7638d5e9 | 87 | for (i=0;i<=7;i++) |
tsuparit | 1:cf9f7638d5e9 | 88 | { |
tsuparit | 1:cf9f7638d5e9 | 89 | INPUT=INPUT+IN[i]; |
tsuparit | 1:cf9f7638d5e9 | 90 | } |
tsuparit | 1:cf9f7638d5e9 | 91 | |
tsuparit | 1:cf9f7638d5e9 | 92 | } |