TSL1401 is the line sensor camera.This library is used to read the raw data. modified Polytec paris sud

Dependents:   app-board-ccd_copy

Fork of TSL1401 by tanabe hitoshi

Committer:
bouaziz
Date:
Fri Jan 26 10:52:00 2018 +0000
Revision:
1:7a8ca2147516
Parent:
0:71198cb26156
test modif CCD polytech paris Sud;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ht 0:71198cb26156 1 #include "TSL1401.h"
bouaziz 1:7a8ca2147516 2 #include "FastIO.h"
bouaziz 1:7a8ca2147516 3 #include "FastAnalogIn.h"
ht 0:71198cb26156 4 /* Macro */
ht 0:71198cb26156 5 #define TAOS_SI_HIGH TAOS_SI = 1
ht 0:71198cb26156 6 #define TAOS_SI_LOW TAOS_SI = 0
ht 0:71198cb26156 7 #define TAOS_CLK_HIGH TAOS_CLK = 1
ht 0:71198cb26156 8 #define TAOS_CLK_LOW TAOS_CLK = 0
ht 0:71198cb26156 9
bouaziz 1:7a8ca2147516 10 FastAnalogIn AA1(p20,0);
ht 0:71198cb26156 11 /* Constructor */
ht 0:71198cb26156 12 TSL1401::TSL1401(PinName s, PinName c, PinName a )
ht 0:71198cb26156 13 {
ht 0:71198cb26156 14
ht 0:71198cb26156 15 SI = s;
ht 0:71198cb26156 16 CLK = c;
ht 0:71198cb26156 17 A0 = new AnalogIn( a );
ht 0:71198cb26156 18 }
ht 0:71198cb26156 19 /* Destructor */
ht 0:71198cb26156 20 TSL1401::~TSL1401()
ht 0:71198cb26156 21 {
ht 0:71198cb26156 22 if( A0 != NULL)
ht 0:71198cb26156 23 {
ht 0:71198cb26156 24 delete A0;
ht 0:71198cb26156 25 }
ht 0:71198cb26156 26 }
ht 0:71198cb26156 27 /* Image Caputure */
ht 0:71198cb26156 28 int *TSL1401::Capture( int LineStart, int LineStop)
ht 0:71198cb26156 29 {
ht 0:71198cb26156 30 int i;
bouaziz 1:7a8ca2147516 31 FastOut<p9> TAOS_SI;
bouaziz 1:7a8ca2147516 32 FastOut<p10> TAOS_CLK;
bouaziz 1:7a8ca2147516 33
bouaziz 1:7a8ca2147516 34 /* DigitalOut TAOS_SI(SI);
ht 0:71198cb26156 35 DigitalOut TAOS_CLK(CLK);
bouaziz 1:7a8ca2147516 36 */
ht 0:71198cb26156 37 Max = 0,Min = 70000;
ht 0:71198cb26156 38 TAOS_SI_HIGH;
ht 0:71198cb26156 39 TAOS_CLK_HIGH;
ht 0:71198cb26156 40 TAOS_SI_LOW;
ht 0:71198cb26156 41 ImageData[0] = 0;
bouaziz 1:7a8ca2147516 42 volatile int *pp=ImageData;
ht 0:71198cb26156 43 TAOS_CLK_LOW;
bouaziz 1:7a8ca2147516 44 /* for(i = 1; i < LineStart; i++) {
bouaziz 1:7a8ca2147516 45 TAOS_CLK_HIGH;
bouaziz 1:7a8ca2147516 46 TAOS_CLK_HIGH;
ht 0:71198cb26156 47 TAOS_CLK_LOW;
ht 0:71198cb26156 48 }
bouaziz 1:7a8ca2147516 49 */
ht 0:71198cb26156 50 for(i = LineStart; i < LineStop; i++) {
ht 0:71198cb26156 51 TAOS_CLK_HIGH;
bouaziz 1:7a8ca2147516 52 // TAOS_CLK_HIGH;
bouaziz 1:7a8ca2147516 53 TAOS_CLK_HIGH;
bouaziz 1:7a8ca2147516 54 // ImageData[i] = A0->read_u16(); // inputs data from camera (one pixel each time through loop)
bouaziz 1:7a8ca2147516 55 // ImageData[i]
bouaziz 1:7a8ca2147516 56 *pp = AA1.read_u16();
ht 0:71198cb26156 57 TAOS_CLK_LOW;
bouaziz 1:7a8ca2147516 58 Max = ( Max < *pp ? *pp : Max);
bouaziz 1:7a8ca2147516 59 // Max = ( Max < ImageData[i] ? ImageData[i] : Max);
bouaziz 1:7a8ca2147516 60 /*if(Max < ImageData[i]){
ht 0:71198cb26156 61 Max = ImageData[i];
bouaziz 1:7a8ca2147516 62 }
bouaziz 1:7a8ca2147516 63 */
bouaziz 1:7a8ca2147516 64 Min = (Min > *pp ? *pp : Min);
bouaziz 1:7a8ca2147516 65 pp++;
bouaziz 1:7a8ca2147516 66 //Min = (Min > ImageData[i] ? ImageData[i] : Min);
bouaziz 1:7a8ca2147516 67
ht 0:71198cb26156 68 }
ht 0:71198cb26156 69 return ImageData;
ht 0:71198cb26156 70 }
ht 0:71198cb26156 71
ht 0:71198cb26156 72
ht 0:71198cb26156 73