]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - apps/tests/msp430/Adc12/TestAdcMultiC.nc
Merge TinyOS 2.1.1 into master.
[tinyos-2.x.git] / apps / tests / msp430 / Adc12 / TestAdcMultiC.nc
index 2115b8bfada279d6ca1908da1710b57b9eaed50b..6a2495031e016980f8eedd8c491f5b8d854b7efb 100644 (file)
@@ -66,10 +66,12 @@ implementation
 {
   
 #define BUFFER_SIZE 100
+#define NUM_REPETITIONS 5
   const msp430adc12_channel_config_t config = {inch, sref, ref2_5v, adc12ssel, adc12div, sht, sampcon_ssel, sampcon_id};
   adc12memctl_t memCtl = {inch2, sref2};
   norace uint8_t state;
   uint16_t buffer[BUFFER_SIZE];
+  norace uint8_t count = 0;
   void task getData();
 
   void task signalFailure()
@@ -102,7 +104,7 @@ implementation
 
   event void Boot.booted()
   {
-    state = 0;
+    count = NUM_REPETITIONS;
     post getData();
   }
 
@@ -119,11 +121,15 @@ implementation
 
   async event void MultiChannel.dataReady(uint16_t *buf, uint16_t numSamples)
   {
-    if (assertData(buf, numSamples) && state++ == 0)
-      post signalSuccess();
-    else
+    if (!assertData(buf, numSamples)){
       post signalFailure();
-    call Resource.release();
+    } else if (count){
+      count--;
+      call MultiChannel.getData();
+    } else {
+      post signalSuccess();
+      call Resource.release();
+    }
   }
 
   command error_t Notify.enable(){}