]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
The commit from Jun 17 that introduced deputy annotations created a problem for the...
authorjanhauer <janhauer>
Mon, 29 Sep 2008 15:51:23 +0000 (15:51 +0000)
committerjanhauer <janhauer>
Mon, 29 Sep 2008 15:51:23 +0000 (15:51 +0000)
apps/tests/msp430/Adc12/TestAdcAppC.nc
apps/tests/msp430/Adc12/TestAdcMultiC.nc
apps/tests/msp430/Adc12/TestAdcSingleC.nc
tos/chips/msp430/adc12/Msp430Adc12ImplP.nc

index 30e176b32b2997e07f009a33d026620e84c3860e..7df22fd1f300cb071f79da85662e1dd475ae8b3f 100644 (file)
@@ -94,7 +94,7 @@ implementation
 
   // Multi, none
   components new TestAdcMultiC(CONFIG_AVCC,
-                     SUPPLY_VOLTAGE_HALF_CHANNEL, REFERENCE_AVcc_AVss) as TestMulti1,
+                     TEMPERATURE_DIODE_CHANNEL, REFERENCE_AVcc_AVss) as TestMulti1,
              new Msp430Adc12ClientC() as Wrapper4;
 
   TestMulti1 -> MainC.Boot;
@@ -104,7 +104,7 @@ implementation
 
   // Multi, RefVolt
   components new TestAdcMultiC(CONFIG_VREF,
-                      SUPPLY_VOLTAGE_HALF_CHANNEL, REFERENCE_VREFplus_AVss) as TestMulti2,
+                      TEMPERATURE_DIODE_CHANNEL, REFERENCE_VREFplus_AVss) as TestMulti2,
              new Msp430Adc12ClientAutoRVGC() as Wrapper5;
 
   TestMulti2 -> MainC.Boot;
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(){}
index e44d9ae4cc2ea7fdd56ff43df7562d9e4e05a1a2..d6ef05e8f8092c4b0fa71e63ab3e53af2fcbcd73 100644 (file)
@@ -62,11 +62,19 @@ generic module TestAdcSingleC(
 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};
-  uint8_t state;
-  norace uint8_t numDone;
+  norace uint8_t state;
+  norace uint8_t count = 0;
   uint16_t buffer[BUFFER_SIZE];
   void task getData();
+  enum {
+    SINGLE_DATA,
+    SINGLE_DATA_REPEAT,
+    MULTIPLE_DATA,
+    MULTIPLE_DATA_REPEAT,
+  };
+
 
   void task signalFailure()
   {
@@ -83,7 +91,7 @@ implementation
 
   event void Boot.booted()
   {
-    state = 0;
+    state = SINGLE_DATA;
     post getData();
   }
 
@@ -99,36 +107,52 @@ implementation
   
   event void Resource.granted()
   {
+    count = NUM_REPETITIONS;
     switch(state)
     {
-      case 0: state++;
-              if (call SingleChannel.configureSingleRepeat(&config, 0) == SUCCESS)
+      case SINGLE_DATA: 
+              if (call SingleChannel.configureSingle(&config) == SUCCESS)
                 call SingleChannel.getData();
               break;
-      case 1: state++;
-              if (call SingleChannel.configureSingle(&config) == SUCCESS)
+      case SINGLE_DATA_REPEAT: 
+              if (call SingleChannel.configureSingleRepeat(&config, 10) == SUCCESS)
                 call SingleChannel.getData();
               break;
-      case 2: state++;
-              if (call SingleChannel.configureMultiple(&config, buffer, BUFFER_SIZE, 0) == SUCCESS)
+      case MULTIPLE_DATA: 
+              if (call SingleChannel.configureMultiple(&config, buffer, BUFFER_SIZE, 10) == SUCCESS)
                 call SingleChannel.getData();
               break;
-      case 3: state++;
-              if (call SingleChannel.configureMultipleRepeat(&config, buffer, 16, 0) == SUCCESS)
+      case MULTIPLE_DATA_REPEAT: 
+              if (call SingleChannel.configureMultipleRepeat(&config, buffer, 16, 10) == SUCCESS)
                 call SingleChannel.getData();
               break;
       default: call Resource.release();
-              if (numDone == state)
-                signal Notify.notify(TRUE);
+              signal Notify.notify(TRUE);
               break;
     }
   }
 
   async event error_t SingleChannel.singleDataReady(uint16_t data)
   { 
-    numDone++;
     assertData(&data, 1);
+    switch(state)
+    {
+      case SINGLE_DATA: 
+              if (count){
+                count--;
+                call SingleChannel.getData();
+                return SUCCESS;
+              }
+              break;
+      case SINGLE_DATA_REPEAT:
+              if (count){
+                count--;
+                return SUCCESS;
+              }
+              break;
+    }
     call Resource.release();
+    state++;
     post getData();
     return FAIL;
   }
@@ -136,9 +160,24 @@ implementation
     
   async event uint16_t* SingleChannel.multipleDataReady(uint16_t *buf, uint16_t length)
   {
-    numDone++;
     assertData(buf, length);
+    switch(state)
+    {
+      case MULTIPLE_DATA: 
+              if (count){
+                count--;
+                call SingleChannel.getData();
+                return 0;
+              }
+              break;
+      case MULTIPLE_DATA_REPEAT:
+              if (count){
+                count--;
+                return buf;
+              }
+    }   
     call Resource.release();
+    state++;
     post getData();
     return 0;
   }
index 0ce8a5450799aa351bee46ebf8407da3ba35afbc..0dabc51a3cc0705eb46233e34adab391662c3949 100644 (file)
@@ -379,7 +379,7 @@ implementation
   {
     atomic {
       if (call ADCArbiterInfo.userId() == id){
-        if (state & MULTIPLE_DATA_REPEAT && !resultBufferStart)
+        if ((state & MULTIPLE_DATA_REPEAT) && !resultBufferStart)
           return EINVAL;
         if (state & ADC_BUSY)
           return EBUSY;
@@ -554,7 +554,7 @@ implementation
       case MULTI_CHANNEL:
         {
           uint16_t i = 0, k;
-          resultBuffer = resultBufferStart;
+          resultBuffer = resultBufferStart + resultBufferIndex;
           do {
             *resultBuffer++ = call HplAdc12.getMem(i);
           } while (++i < numChannels);
@@ -566,7 +566,7 @@ implementation
             resultBufferIndex = 0;
             signal MultiChannel.dataReady[clientID](resultBuffer, 
                 overflow ? k : resultBufferLength);
-          } else call HplAdc12.enableConversion();
+          }
         }
         break;
       case MULTIPLE_DATA: