]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
Added a temporary workaround that allows to compile msp430 ADC code with mspgcc versi...
authorjan.hauer <jan.hauer@285f258d-8064-b571-fbc6-9656dc998e90>
Wed, 9 Mar 2011 15:26:12 +0000 (15:26 +0000)
committerR. Steve McKown <rsmckown@gmail.com>
Tue, 2 Oct 2012 01:53:18 +0000 (19:53 -0600)
git-svn-id: http://tinyos-main.googlecode.com/svn/trunk@5503 285f258d-8064-b571-fbc6-9656dc998e90

tos/chips/msp430/adc12/Msp430Adc12.h
tos/chips/msp430/adc12/Msp430Adc12DMAP.nc

index 6e6854e8850ef04fb08f747a0243c6b900d7e80a..da9e8359bd8e590b3f051e1fe5af86e04dec4f16 100644 (file)
@@ -164,19 +164,63 @@ enum sampcon_id_enum
 // The unique string for accessing HAL2 via ReadStream
 #define ADCC_READ_STREAM_SERVICE "AdcC.ReadStream.Client"
 
-/* Test for GCC bug (bitfield access) - only version 3.2.3 is known to be stable */
-// TODO: check whether this is still relevant...
-#define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__ * 10 + __GNUC_PATCHLEVEL__)
-#if GCC_VERSION == 332
-#error "The msp430-gcc version (3.3.2) contains a bug which results in false accessing \
-of bitfields in structs and makes MSP430ADC12M.nc fail ! Use version 3.2.3 instead."
-#elif GCC_VERSION != 323
-#warning "This version of msp430-gcc might contain a bug which results in false accessing \
-of bitfields in structs (MSP430ADC12M.nc would fail). Use version 3.2.3 instead."
-#endif  
-
-#ifndef __msp430_have_adc12
-#error MSP430ADC12C: Target msp430 device does not have ADC12 module
+
+
+#ifdef __MSP430_TI_HEADERS__
+//#if __GNUC__ >= 4
+  
+  // "The bitfield structures that overlay peripheral registers are not part of
+  // mspgcc in the future; the recommended way of accessing those fields is to
+  // use the masks defined in the TI headers."
+  // (https://www.millennium.berkeley.edu/pipermail/tinyos-devel/2011-March/004804.html)
+  //
+  // Until the ADC driver is updated our temporary workaround is to re-define
+  // the old structures -- this may may result in faulty ADC code and should be
+  // checked carefully for your specific device (note: msp430x1611 is safe)!
+
+#warning "Accessing Adc12 registers via bitfield structures: this is discouraged mspgcc version >= 4 as it may result in faulty code!" 
+
+typedef struct {
+  volatile unsigned
+    adc12sc:1,
+    enc:1,
+    adc12tovie:1,
+    adc12ovie:1,
+    adc12on:1,
+    refon:1,
+    r2_5v:1,
+    msc:1,
+    sht0:4,
+    sht1:4;
+} __attribute__ ((packed)) adc12ctl0_t;
+
+typedef struct {
+  volatile unsigned
+    adc12busy:1,
+    conseq:2,
+    adc12ssel:2,
+    adc12div:3,
+    issh:1,
+    shp:1,
+    shs:2,
+    cstartadd:4;
+} __attribute__ ((packed)) adc12ctl1_t;
+
+#else
+
+  /* Test for GCC bug (bitfield access) - only version 3.2.3 is known to be stable */
+  #define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__ * 10 + __GNUC_PATCHLEVEL__)
+  #if GCC_VERSION == 332
+    #error "This msp430-gcc version (3.3.2) is known to contain a bug when accessing bitfield structs."
+  #elif GCC_VERSION != 323
+    #warning "This version of msp430-gcc might contain a bug when accessing bitfield structs (version 3.2.3 is safe - anything else is on your own risk)"
+  #endif  
+
+#endif
+
+
+#if !defined(__msp430_have_adc12) && !defined(__MSP430_HAS_ADC12__)
+#error Target msp430 device does not have ADC12 module
 #endif
 
 #endif
index bd8c8a0acc98a0302810ef5b1103acc29bf81dca..a07d38cfa006e9225cb0ad0ee0ea7c001b122848 100644 (file)
@@ -92,7 +92,7 @@ implementation
         DMA_REPEATED_SINGLE_TRANSFER, 
         DMA_TRIGGER_ADC12IFGx,
         DMA_EDGE_SENSITIVE,
-        ADC12MEM,
+        (void*) ADC12MEM_,
         buf,
         length,
         DMA_WORD,
@@ -127,7 +127,7 @@ implementation
   async command error_t SingleChannel.getData[uint8_t id]()
   {
     if (mode == MULTIPLE_SINGLE_AGAIN)
-      call DMAChannel.repeatTransfer(ADC12MEM, buffer, numSamples);
+      call DMAChannel.repeatTransfer((void*) ADC12MEM_, buffer, numSamples);
     return call SubSingleChannel.getData[id]();
   }
   
@@ -154,7 +154,7 @@ implementation
     next = signal SingleChannel.multipleDataReady[client](buffer, numSamples);
     if (oldMode == MULTIPLE_REPEAT)
       if (next){
-        call DMAChannel.repeatTransfer(ADC12MEM, next, numSamples);
+        call DMAChannel.repeatTransfer((void*) ADC12MEM_, next, numSamples);
         call AsyncAdcControl.start[client]();
       } else
         call AsyncAdcControl.stop[client]();