Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed FastIO FastPWM USBDevice
Fork of Pinscape_Controller by
Diff: TSL14xx/TSL14xx.h
- Revision:
- 104:6e06e0f4b476
- Parent:
- 101:755f44622abc
--- a/TSL14xx/TSL14xx.h Tue Dec 03 19:10:52 2019 +0000
+++ b/TSL14xx/TSL14xx.h Fri Dec 27 20:14:23 2019 +0000
@@ -19,14 +19,9 @@
* (Note on the plunger sensor class hierarchy: this class is for the
* sensor only, not for the plunger application. This class is meant
* to be reusable in other contexts that just need to read raw pixel
- * data from the sensor. Plunger/tslxxSensor.h implements the next
- * level up, which is the implementation of the generic plunger sensor
- * interface for TSL14xx sensors. That's still an abstract class, since
- * it only provides the plunger class specialization for these sensor
- * types, without any image analysis component. The final concrete
- * classes are in Plunger/edgeSensor.h and Plunger/barCodeSensor.h,
- * which add the image processing that analyzes the image data to
- * determine the plunger position.)
+ * data from the sensor. Plunger/tslxxSensor.h implements the
+ * specializations of the plunger interface class for these sensors.)
+ *
*
* *** Double buffering ***
*
@@ -540,17 +535,17 @@
// to wait to start the next cycle until we've reached the desired
// total integration time.
uint32_t dt = now - tInt;
- if (dt < tIntMin)
- {
- // more time is required - set a timeout for the remaining inteval
- integrationTimeout.attach_us(this, &TSL14xx::startTransfer, tIntMin - dt);
- }
- else
- {
- // we've already reached the minimum integration time - start
- // the next transfer immediately
- startTransfer();
- }
+
+ // Figure the time to the start of the next transfer. Wait for the
+ // remainder of the current integration period if we haven't yet
+ // reached the requested minimum, otherwise just start almost
+ // immediately. (Not *actually* immediately: we don't want to start
+ // the new transfer within this interrupt handler, because the DMA
+ // IRQ doesn't reliably clear if we start a new transfer immediately.)
+ uint32_t dtNext = dt < tIntMin ? tIntMin - dt : 1;
+
+ // Schedule the next transfer
+ integrationTimeout.attach_us(this, &TSL14xx::startTransfer, dtNext);
}
// Clear the sensor shift register. Clocks in all of the pixels from
