]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
simplified interface
authorandreaskoepke <andreaskoepke>
Thu, 6 Dec 2007 18:33:02 +0000 (18:33 +0000)
committerandreaskoepke <andreaskoepke>
Thu, 6 Dec 2007 18:33:02 +0000 (18:33 +0000)
tos/platforms/eyesIFX/sensors/CoulombCounter.nc
tos/platforms/eyesIFX/sensors/CoulombCounterP.nc

index 2ae7848f971fc7922e3e220269c1eaf11c3fad02..0ce2c9437f827bb83ed125dedd6a81897341c947 100644 (file)
@@ -46,11 +46,14 @@ interface CoulombCounter {
      *  re-boot every time we fiddle with the power supply -- this trick
      *  allows us to "continue" measureing.
      */
-    command error_t startMeasurement(uint32_t delay, uint32_t duration);
+    command error_t start(uint32_t delay, uint32_t duration);
 
     /** Stop a measurement, returns FAIL if there is no ongoing measurement */
-    command error_t stopMeasurement();
+    command error_t stop();
 
     /** notification: a fixed portion of energy has been consumed */
     async event void portionConsumed();
+
+    /** notification that the measurement will be soon over */
+    event void soonOver();
 }
index edba1ef00a33f8fd714dc9673a514fc74a6aa4c2..32c74413460887521e3fca10ef1db13136ee1e73 100644 (file)
@@ -49,11 +49,12 @@ module CoulombCounterP {
     }
 }
 implementation {
-#define MIN_DELAY 30
+#define MIN_DELAY 60
     
     uint16_t timerHighBits = 0;
     uint32_t dur = 0;
-
+    bool warned = FALSE;
+    
     void resetBoard() {
         call ResetBoard.set();
         __asm__("NOP");
@@ -106,12 +107,12 @@ implementation {
         }
     }
     
-    command error_t CoulombCounter.startMeasurement(uint32_t delay, uint32_t duration) {
+    command error_t CoulombCounter.start(uint32_t delay, uint32_t duration) {
         error_t result = SUCCESS;
         
         timerHighBits = duration >> 22;
         dur = duration * (uint32_t)1024;
-        
+        warned = FALSE;
         if(call CoulombCounter.isMeasureing()) {
             startLongTimer();
             call EnergyInterrupt.enableFallingEdge();
@@ -128,7 +129,7 @@ implementation {
     }
 
     /** Stop a measurement, returns FAIL if there is no ongoing measurement */
-    command error_t CoulombCounter.stopMeasurement() {
+    command error_t CoulombCounter.stop() {
         error_t result = FAIL;
         call Timer.stop();
         timerHighBits = 0;
@@ -151,8 +152,14 @@ implementation {
                 startLongTimer();
             }
             else {
-                // measurement finished
-                call CoulombCounter.stopMeasurement();
+                if(warned == TRUE) {
+                    call CoulombCounter.stop();
+                }
+                else {
+                    signal CoulombCounter.soonOver();
+                    call Timer.startOneShot((uint32_t)MIN_DELAY*1024);
+                    warned = TRUE;
+                }
             }
         }
         else {