From: janhauer Date: Mon, 29 Sep 2008 15:51:23 +0000 (+0000) Subject: The commit from Jun 17 that introduced deputy annotations created a problem for the... X-Git-Tag: rc_6_tinyos_2_1_1~597 X-Git-Url: https://oss.titaniummirror.com/gitweb/?p=tinyos-2.x.git;a=commitdiff_plain;h=9b05e249020c375245923f40c3391b1ac4b61389 The commit from Jun 17 that introduced deputy annotations created a problem for the MultiChannel interface in Msp430Adc12ImplP ISR - this is now fixed. I also extended the test app. --- diff --git a/apps/tests/msp430/Adc12/TestAdcAppC.nc b/apps/tests/msp430/Adc12/TestAdcAppC.nc index 30e176b3..7df22fd1 100644 --- a/apps/tests/msp430/Adc12/TestAdcAppC.nc +++ b/apps/tests/msp430/Adc12/TestAdcAppC.nc @@ -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; diff --git a/apps/tests/msp430/Adc12/TestAdcMultiC.nc b/apps/tests/msp430/Adc12/TestAdcMultiC.nc index 2115b8bf..6a249503 100644 --- a/apps/tests/msp430/Adc12/TestAdcMultiC.nc +++ b/apps/tests/msp430/Adc12/TestAdcMultiC.nc @@ -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(){} diff --git a/apps/tests/msp430/Adc12/TestAdcSingleC.nc b/apps/tests/msp430/Adc12/TestAdcSingleC.nc index e44d9ae4..d6ef05e8 100644 --- a/apps/tests/msp430/Adc12/TestAdcSingleC.nc +++ b/apps/tests/msp430/Adc12/TestAdcSingleC.nc @@ -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; } diff --git a/tos/chips/msp430/adc12/Msp430Adc12ImplP.nc b/tos/chips/msp430/adc12/Msp430Adc12ImplP.nc index 0ce8a545..0dabc51a 100644 --- a/tos/chips/msp430/adc12/Msp430Adc12ImplP.nc +++ b/tos/chips/msp430/adc12/Msp430Adc12ImplP.nc @@ -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: