]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
Now returns an error if ADC12_TIMERA_ENABLED is not defined but configuration require...
authorjanhauer <janhauer>
Mon, 10 Nov 2008 14:56:12 +0000 (14:56 +0000)
committerjanhauer <janhauer>
Mon, 10 Nov 2008 14:56:12 +0000 (14:56 +0000)
tos/chips/msp430/adc12/AdcStreamP.nc
tos/chips/msp430/adc12/Msp430Adc12ImplP.nc

index 7bc24f87ba6918540151e09ab2bd93b621de56f3..a7f623865782e034497c650cd07825ea98949ec8 100644 (file)
@@ -93,7 +93,8 @@ implementation {
     call SingleChannel.getData[client]();
   }
 
-  command error_t ReadStream.postBuffer[uint8_t c](uint16_t *buf, uint16_t n) {
+  error_t postBuffer(uint8_t c, uint16_t *buf, uint16_t n)
+  {
     if (n < sizeof(struct list_entry_t))
       return ESIZE;
     atomic
@@ -111,6 +112,10 @@ implementation {
     return SUCCESS;
   }
 
+  command error_t ReadStream.postBuffer[uint8_t c](uint16_t *buf, uint16_t n) {
+    return postBuffer(c, buf, n);
+  }
+
   task void readStreamDone() {
     uint8_t c = client;
     uint32_t actualPeriod = period;
@@ -204,8 +209,12 @@ implementation {
       msp430adc12_channel_config_t config = *call AdcConfigure.getConfiguration[c]();
       config.sampcon_ssel = SAMPCON_SOURCE_SMCLK; // assumption: SMCLK runs at 1 MHz
       config.sampcon_id = SAMPCON_CLOCK_DIV_1; 
-      call SingleChannel.configureMultiple[c]( &config, pos, count, period);
-      call SingleChannel.getData[c]();
+      if (call SingleChannel.configureMultiple[c]( &config, pos, count, period) == SUCCESS)
+        call SingleChannel.getData[c]();
+      else {
+        postBuffer(c, pos, count);
+        post readStreamFail();
+      }
     }
   }
 
index 0dabc51a3cc0705eb46233e34adab391662c3949..e9e7f68e869dd8f07bee73dbd5bb08d86d407252 100644 (file)
@@ -63,7 +63,11 @@ module Msp430Adc12ImplP @safe()
 }
 implementation
 { 
-#warning Accessing TimerA for ADC12 
+
+#ifdef ADC12_TIMERA_ENABLED
+  #warning Accessing TimerA for ADC12 
+#endif
+
   enum {
     SINGLE_DATA = 1,
     SINGLE_DATA_REPEAT = 2,
@@ -218,6 +222,10 @@ implementation
   {
     error_t result = ERESERVE;
 #ifdef ADC12_CHECK_ARGS
+#ifndef ADC12_TIMERA_ENABLED
+    if (jiffies>0) 
+      return EINVAL;
+#endif
     if (!config || jiffies == 1 || jiffies == 2)
       return EINVAL;
 #endif
@@ -266,6 +274,10 @@ implementation
   {
     error_t result = ERESERVE;
 #ifdef ADC12_CHECK_ARGS
+#ifndef ADC12_TIMERA_ENABLED
+    if (jiffies>0) 
+      return EINVAL;
+#endif
     if (!config || !buf || !length || jiffies == 1 || jiffies == 2)
       return EINVAL;
 #endif
@@ -323,6 +335,10 @@ implementation
   {
     error_t result = ERESERVE;
 #ifdef ADC12_CHECK_ARGS
+#ifndef ADC12_TIMERA_ENABLED
+    if (jiffies>0) 
+      return EINVAL;
+#endif
     if (!config || !buf || !length || length > 16 || jiffies == 1 || jiffies == 2)
       return EINVAL;
 #endif
@@ -402,6 +418,10 @@ implementation
   {
     error_t result = ERESERVE;
 #ifdef ADC12_CHECK_ARGS
+#ifndef ADC12_TIMERA_ENABLED
+    if (jiffies>0) 
+      return EINVAL;
+#endif
     if (!config || !memctl || !numMemctl || numMemctl > 15 || !numSamples || 
         !buf || jiffies == 1 || jiffies == 2 || numSamples % (numMemctl+1) != 0)
       return EINVAL;