fingersensors.c

Go to the documentation of this file.
00001 /*
00002  * finger sensors control
00003  * 
00004  * (c) 2007 by Matthias Arndt <matthias.arndt@tu-clausthal.de>
00005  *
00006  * Matrix enable: P1.6 P1.7
00007  * analogue outputs: P1.1 P1.2
00008  *
00009  * indices of readings:
00010  * 0 ... finger lower sensor
00011  * 1 ... finger upper sensor
00012  * 2 ... right finger top
00013  * 3 ... left finger top (Sharp equipped finger)
00014  */
00016 #include "t89c51cc02.h"
00017 #include "datatypes.h"
00018 #include "fingersensors.h"
00019 #include "adc.h"
00020 
00026 WORD idata fingersensors[FINGERSENSORS_NR];
00027 
00033 void Fingersensors_init()
00034 {
00035         BYTE i;
00036         for(i=0;i<FINGERSENSORS_NR;i++)
00037                 fingersensors[i]=0;
00038 
00039         ADCF |= 0x06; /* activate P1.1 and P1.2 as analogue inputs */   
00040         
00041         Fingersensors_PowerOff();
00042 }
00043 
00049 void Fingersensors_read()
00050 {
00051         Fingersensors_SelectBank1();    /* activate one column of the control matrix */
00052         _asm
00053         nop
00054         nop
00055         nop
00056         nop
00057         _endasm;
00058 
00059         fingersensors[0]=ADC(1);        /* read finger sensor 1 */
00060         _asm
00061         nop
00062         nop
00063         nop
00064         nop
00065         _endasm;
00066         fingersensors[1]=ADC(2);        /* read finger sensor 2 */
00067         _asm
00068         nop
00069         nop
00070         nop
00071         nop
00072         _endasm;
00073         Fingersensors_SelectBank2();    /* activate other column */
00074         _asm
00075         nop
00076         nop
00077         nop
00078         nop
00079         _endasm;
00080         fingersensors[2]=ADC(1);        /* read finger sensor 3 */
00081         _asm
00082         nop
00083         nop
00084         nop
00085         nop
00086         _endasm;
00087         fingersensors[3]=ADC(2);        /* read finger sensor 4 */
00088         _asm
00089         nop
00090         nop
00091         nop
00092         nop
00093         _endasm;
00094         Fingersensors_PowerOff();
00095 }

Generated on Wed Oct 24 12:57:24 2007 for SensorControl by  doxygen 1.4.6