From d098e571892462ba0f277b0593cc1b48eeda6dba Mon Sep 17 00:00:00 2001 From: janhauer Date: Mon, 10 Nov 2008 14:56:12 +0000 Subject: [PATCH] Now returns an error if ADC12_TIMERA_ENABLED is not defined but configuration requires TimerA. --- tos/chips/msp430/adc12/AdcStreamP.nc | 15 ++++++++++++--- tos/chips/msp430/adc12/Msp430Adc12ImplP.nc | 22 +++++++++++++++++++++- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/tos/chips/msp430/adc12/AdcStreamP.nc b/tos/chips/msp430/adc12/AdcStreamP.nc index 7bc24f87..a7f62386 100644 --- a/tos/chips/msp430/adc12/AdcStreamP.nc +++ b/tos/chips/msp430/adc12/AdcStreamP.nc @@ -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(); + } } } diff --git a/tos/chips/msp430/adc12/Msp430Adc12ImplP.nc b/tos/chips/msp430/adc12/Msp430Adc12ImplP.nc index 0dabc51a..e9e7f68e 100644 --- a/tos/chips/msp430/adc12/Msp430Adc12ImplP.nc +++ b/tos/chips/msp430/adc12/Msp430Adc12ImplP.nc @@ -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; -- 2.39.2