Pinscape Controller version 1 fork. This is a fork to allow for ongoing bug fixes to the original controller version, from before the major changes for the expansion board project.

Dependencies:   FastIO FastPWM SimpleDMA mbed

Fork of Pinscape_Controller by Mike R

Revision:
40:cc0d9814522b
Parent:
35:e959ffba78fd
Child:
43:7a6364d82a41
diff -r b3815a1c3802 -r cc0d9814522b TSL1410R/tsl1410r.h
--- a/TSL1410R/tsl1410r.h	Mon Jan 11 21:08:36 2016 +0000
+++ b/TSL1410R/tsl1410r.h	Wed Feb 03 22:57:25 2016 +0000
@@ -126,7 +126,7 @@
                 pix[dst] = ao1.read_u16();
                 pix[dst+n/2] = ao2.read_u16();
                 
-                // turn off the ADC until the next pixel is ready
+                // turn off the ADC until the next pixel is clocked out
                 ao1.disable();
                 ao2.disable();
                 
@@ -188,8 +188,12 @@
         si = 0;
         clockPort->PCOR |= clockMask;
         
+        // if in serial mode, clock all pixels across both sensor halves;
+        // in parallel mode, the pixels are clocked together
+        int n = parallel ? nPix/2 : nPix;
+        
         // clock out all pixels
-        for (int i = 0 ; i < nPix + 1 ; ++i) {
+        for (int i = 0 ; i < n + 1 ; ++i) {
             clockPort->PSOR |= clockMask;
             clockPort->PCOR |= clockMask;
         }
@@ -197,13 +201,13 @@
 
 private:
     int nPix;                 // number of pixels in physical sensor array
-    DigitalOut si;
-    DigitalOut clock;
-    FGPIO_Type *clockPort;    // IOPORT base address for clock pin, for fast writes
+    DigitalOut si;            // GPIO pin for sensor SI (serial data) 
+    DigitalOut clock;         // GPIO pin for sensor SCLK (serial clock)
+    FGPIO_Type *clockPort;    // IOPORT base address for clock pin - cached for fast writes
     uint32_t clockMask;       // IOPORT register bit mask for clock pin
-    FastAnalogIn ao1; 
-    FastAnalogIn ao2;         // valid iff running in parallel mode
-    bool parallel;            // true -> running in parallel mode
+    FastAnalogIn ao1;         // GPIO pin for sensor AO1 (analog output 1) - we read sensor data from this pin
+    FastAnalogIn ao2;         // GPIO pin for sensor AO2 (analog output 2) - 2nd sensor data pin, when in parallel mode
+    bool parallel;            // true -> running in parallel mode (we read AO1 and AO2 separately on each clock)
 };
  
 #endif /* TSL1410R_H */