// 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
DMA_REPEATED_SINGLE_TRANSFER,
DMA_TRIGGER_ADC12IFGx,
DMA_EDGE_SENSITIVE,
- ADC12MEM,
+ (void*) ADC12MEM_,
buf,
length,
DMA_WORD,
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]();
}
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]();