[Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/msp430/Adc12
EvaluatorC.nc, NONE, 1.1 TestAdcMultiC.nc, NONE,
1.1 TestAdcSingleC.nc, NONE, 1.1 evaluator.h, NONE,
1.1 TestAdcAppC.nc, 1.1, 1.2
Jan-Hinrich Hauer
janhauer at users.sourceforge.net
Mon Jun 25 08:43:41 PDT 2007
- Previous message: [Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/msp430/adc12
Msp430Adc12ConfAlertC.nc, NONE,
1.1 Msp430Adc12ClientAutoRVGC.nc, 1.5,
1.6 Msp430Adc12ClientAutoDMA_RVGC.nc, 1.5, 1.6
- Next message: [Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/msp430/adc12
Msp430Adc12.h, 1.4, 1.5 Msp430Adc12ImplP.nc, 1.4,
1.5 Msp430Adc12P.nc, 1.4, 1.5 README.txt, 1.5, 1.6
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-2.x/apps/tests/msp430/Adc12
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv11140
Modified Files:
TestAdcAppC.nc
Added Files:
EvaluatorC.nc TestAdcMultiC.nc TestAdcSingleC.nc evaluator.h
Log Message:
Example application demonstrating the use of all commands/events in
Msp430Adc12SingleChannel and Msp430Adc12MultiChannel via different
ADC wrappers.
--- NEW FILE: EvaluatorC.nc ---
/*
* Copyright (c) 2007, Technische Universitaet Berlin
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the Technische Universitaet Berlin nor the names
* of its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* - Revision -------------------------------------------------------------
* $Revision: 1.1 $
* $Date: 2007/06/25 15:43:37 $
* @author: Jan Hauer <hauer at tkn.tu-berlin.de>
* ========================================================================
*/
/**
* Checks whether all clients signalled Notify.notify(TRUE) and
* only then switches all three LEDs on. Displays on LEDs (binary)
* the ID of the first unsuccessful client otherwise.
*
* Author: Jan Hauer
**/
#include "evaluator.h"
module EvaluatorC
{
uses {
interface Leds;
interface Notify<bool> as Notify[uint8_t client];
}
}
implementation
{
enum {
NUM_CLIENTS = uniqueCount(EVALUATOR_CLIENT),
};
int numSuccess = 0;
void display(uint8_t client)
{
if (client & 0x1)
call Leds.led0On();
else
call Leds.led0Off();
if (client & 0x2)
call Leds.led1On();
else
call Leds.led1Off();
if (client & 0x4)
call Leds.led2On();
else
call Leds.led2Off();
}
event void Notify.notify[uint8_t client]( bool val )
{
if (val)
numSuccess++;
else {
if (client != 7) // would look like a success
display(client);
numSuccess = -1000;
}
if (NUM_CLIENTS == numSuccess){
call Leds.led0On();
call Leds.led1On();
call Leds.led2On();
}
}
}
--- NEW FILE: TestAdcMultiC.nc ---
/*
* Copyright (c) 2007, Technische Universitaet Berlin
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the Technische Universitaet Berlin nor the names
* of its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* - Revision -------------------------------------------------------------
* $Revision: 1.1 $
* $Date: 2007/06/25 15:43:37 $
* @author: Jan Hauer <hauer at tkn.tu-berlin.de>
* ========================================================================
*/
/**
* Testing MultiChannel HAL interface of ADC12 on msp430.
*
* Author: Jan Hauer
**/
generic module TestAdcMultiC(
uint8_t inch, // first input channel
uint8_t sref, // reference voltage
uint8_t ref2_5v, // reference voltage level
uint8_t adc12ssel, // clock source sample-hold-time
uint8_t adc12div, // clock divider sample-hold-time
uint8_t sht, // sample-hold-time
uint8_t sampcon_ssel, // clock source sampcon signal
uint8_t sampcon_id, // clock divider sampcon
uint8_t inch2, // second input channel
uint8_t sref2 // second reference voltage
)
{
uses {
interface Boot;
interface Resource;
interface Msp430Adc12MultiChannel as MultiChannel;
}
provides {
interface Notify<bool>;
interface AdcConfigure<const msp430adc12_channel_config_t*>;
}
}
implementation
{
#define BUFFER_SIZE 100
const msp430adc12_channel_config_t config = {inch, sref, ref2_5v, adc12ssel, adc12div, sht, sampcon_ssel, sampcon_id};
adc12memctl_t memCtl = {inch2, sref2};
uint8_t state;
uint16_t buffer[BUFFER_SIZE];
void task getData();
void task signalFailure()
{
signal Notify.notify(FALSE);
}
void task signalSuccess()
{
signal Notify.notify(TRUE);
}
bool assertData(uint16_t *data, uint16_t num)
{
uint16_t i;
for (i=0; i<num; i++)
if (!data[i] || data[i] >= 0xFFF){
post signalFailure();
return FALSE;
}
return TRUE;
}
async command const msp430adc12_channel_config_t* AdcConfigure.getConfiguration()
{
return &config;
}
event void Boot.booted()
{
state = 0;
post getData();
}
void task getData()
{
call Resource.request();
}
event void Resource.granted()
{
if (call MultiChannel.configure(&config, &memCtl, 1, buffer, BUFFER_SIZE, 0) == SUCCESS)
call MultiChannel.getData();
}
async event void MultiChannel.dataReady(uint16_t *buf, uint16_t numSamples)
{
if (assertData(buf, numSamples))
post signalSuccess();
call Resource.release();
}
command error_t Notify.enable(){}
command error_t Notify.disable(){}
}
--- NEW FILE: TestAdcSingleC.nc ---
/*
* Copyright (c) 2007, Technische Universitaet Berlin
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the Technische Universitaet Berlin nor the names
* of its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* - Revision -------------------------------------------------------------
* $Revision: 1.1 $
* $Date: 2007/06/25 15:43:37 $
* @author: Jan Hauer <hauer at tkn.tu-berlin.de>
* ========================================================================
*/
/**
* Testing SingleChannel HAL interface of ADC12 on msp430.
*
* Author: Jan Hauer
**/
generic module TestAdcSingleC(
uint8_t inch, // input channel
uint8_t sref, // reference voltage
uint8_t ref2_5v, // reference voltage level
uint8_t adc12ssel, // clock source sample-hold-time
uint8_t adc12div, // clock divider sample-hold-time
uint8_t sht, // sample-hold-time
uint8_t sampcon_ssel, // clock source sampcon signal
uint8_t sampcon_id // clock divider sampcon
)
{
uses {
interface Boot;
interface Resource;
interface Msp430Adc12SingleChannel as SingleChannel;
}
provides {
interface AdcConfigure<const msp430adc12_channel_config_t*>;
interface Notify<bool>;
}
}
implementation
{
#define BUFFER_SIZE 100
const msp430adc12_channel_config_t config = {inch, sref, ref2_5v, adc12ssel, adc12div, sht, sampcon_ssel, sampcon_id};
uint8_t state;
uint16_t buffer[BUFFER_SIZE];
void task getData();
void task signalFailure()
{
signal Notify.notify(FALSE);
}
void assertData(uint16_t *data, uint16_t num)
{
uint16_t i;
for (i=0; i<num; i++)
if (!data[i] || data[i] >= 0xFFF)
post signalFailure();
}
event void Boot.booted()
{
state = 0;
post getData();
}
async command const msp430adc12_channel_config_t* AdcConfigure.getConfiguration()
{
return &config;
}
void task getData()
{
call Resource.request();
}
event void Resource.granted()
{
switch(state)
{
case 0: state++;
if (call SingleChannel.configureSingleRepeat(&config, 0) == SUCCESS)
call SingleChannel.getData();
break;
case 1: state++;
if (call SingleChannel.configureSingle(&config) == SUCCESS)
call SingleChannel.getData();
break;
case 2: state++;
if (call SingleChannel.configureMultiple(&config, buffer, BUFFER_SIZE, 0) == SUCCESS)
call SingleChannel.getData();
break;
case 3: state++;
if (call SingleChannel.configureMultipleRepeat(&config, buffer, 16, 0) == SUCCESS)
call SingleChannel.getData();
break;
default: call Resource.release();
signal Notify.notify(TRUE);
break;
}
}
async event error_t SingleChannel.singleDataReady(uint16_t data)
{
assertData(&data, 1);
call Resource.release();
post getData();
return FAIL;
}
async event uint16_t* SingleChannel.multipleDataReady(uint16_t *buf, uint16_t length)
{
assertData(buf, length);
call Resource.release();
post getData();
return 0;
}
command error_t Notify.enable(){}
command error_t Notify.disable(){}
}
--- NEW FILE: evaluator.h ---
#ifndef EVALUATOR_H
#define EVALUATOR_H
#define EVALUATOR_CLIENT "ADC12.Evalutator.ID"
#endif
Index: TestAdcAppC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/apps/tests/msp430/Adc12/TestAdcAppC.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** TestAdcAppC.nc 5 Apr 2007 13:45:08 -0000 1.1
--- TestAdcAppC.nc 25 Jun 2007 15:43:37 -0000 1.2
***************
*** 35,66 ****
/**
! * Testing HAL of ADC12 on msp430. Switches three LEDs on, if successful.
*
* Author: Jan Hauer
*/
#include "Msp430Adc12.h"
configuration TestAdcAppC {
}
implementation
{
! components MainC,
! new TestAdcC(REFVOLT_LEVEL_1_5) as TestAdcC1,
! new Msp430Adc12ClientAutoRVGC() as Wrapper1,
! LedsC;
! TestAdcC1 -> MainC.Boot;
! TestAdcC1.Leds -> LedsC;
! TestAdcC1.Resource -> Wrapper1;
! TestAdcC1.SingleChannel -> Wrapper1.Msp430Adc12SingleChannel;
! Wrapper1.AdcConfigure -> TestAdcC1;
! components new TestAdcC(REFVOLT_LEVEL_2_5) as TestAdcC2,
! new Msp430Adc12ClientAutoRVGC() as Wrapper2;
- TestAdcC2 -> MainC.Boot;
- TestAdcC2.Leds -> LedsC;
- TestAdcC2.Resource -> Wrapper2;
- TestAdcC2.SingleChannel -> Wrapper2.Msp430Adc12SingleChannel;
- Wrapper2.AdcConfigure -> TestAdcC2;
}
--- 35,117 ----
/**
! * Testing HAL of ADC12 on msp430. Switches three LEDs on, if the test was
! * successful.
*
* Author: Jan Hauer
*/
#include "Msp430Adc12.h"
+ #include "evaluator.h"
configuration TestAdcAppC {
}
implementation
{
! // msp430 internal temperature sensor with ref volt from generator
! #define CONFIG_VREF TEMPERATURE_DIODE_CHANNEL, REFERENCE_VREFplus_AVss, REFVOLT_LEVEL_2_5, SHT_SOURCE_ACLK, SHT_CLOCK_DIV_1, SAMPLE_HOLD_4_CYCLES, SAMPCON_SOURCE_SMCLK, SAMPCON_CLOCK_DIV_1
! // msp430 internal temperature sensor with ref volt from AVcc
! #define CONFIG_AVCC TEMPERATURE_DIODE_CHANNEL, REFERENCE_AVcc_AVss, REFVOLT_LEVEL_NONE, SHT_SOURCE_SMCLK, SHT_CLOCK_DIV_1, SAMPLE_HOLD_4_CYCLES, SAMPCON_SOURCE_SMCLK, SAMPCON_CLOCK_DIV_1
!
! components MainC, LedsC, EvaluatorC;
! EvaluatorC.Leds -> LedsC;
! // Single, none
! components new TestAdcSingleC(CONFIG_AVCC) as TestSingle0,
! new Msp430Adc12ClientC() as Wrapper0;
!
! TestSingle0 -> MainC.Boot;
! TestSingle0.Resource -> Wrapper0;
! TestSingle0.SingleChannel -> Wrapper0.Msp430Adc12SingleChannel;
! EvaluatorC.Notify[unique(EVALUATOR_CLIENT)] -> TestSingle0;
!
! // Single, RefVolt
! components new TestAdcSingleC(CONFIG_VREF) as TestSingle1,
! new Msp430Adc12ClientAutoRVGC() as Wrapper1;
!
! TestSingle1 -> MainC.Boot;
! TestSingle1.Resource -> Wrapper1;
! TestSingle1.SingleChannel -> Wrapper1.Msp430Adc12SingleChannel;
! EvaluatorC.Notify[unique(EVALUATOR_CLIENT)] -> TestSingle1;
! Wrapper1.AdcConfigure -> TestSingle1;
!
! // Single, DMA
! components new TestAdcSingleC(CONFIG_AVCC) as TestSingle2,
! new Msp430Adc12ClientAutoDMAC() as Wrapper2;
!
! TestSingle2 -> MainC.Boot;
! TestSingle2.Resource -> Wrapper2;
! TestSingle2.SingleChannel -> Wrapper2.Msp430Adc12SingleChannel;
! EvaluatorC.Notify[unique(EVALUATOR_CLIENT)] -> TestSingle2;
!
! // Single, RefVolt + DMA
! components new TestAdcSingleC(CONFIG_VREF) as TestSingle3,
! new Msp430Adc12ClientAutoDMA_RVGC() as Wrapper3;
!
! TestSingle3 -> MainC.Boot;
! TestSingle3.Resource -> Wrapper3;
! TestSingle3.SingleChannel -> Wrapper3.Msp430Adc12SingleChannel;
! EvaluatorC.Notify[unique(EVALUATOR_CLIENT)] -> TestSingle3;
! Wrapper3.AdcConfigure -> TestSingle3;
!
! // Multi, none
! components new TestAdcMultiC(CONFIG_AVCC,
! SUPPLY_VOLTAGE_HALF_CHANNEL, REFERENCE_AVcc_AVss) as TestMulti1,
! new Msp430Adc12ClientC() as Wrapper4;
!
! TestMulti1 -> MainC.Boot;
! TestMulti1.Resource -> Wrapper4;
! TestMulti1.MultiChannel -> Wrapper4.Msp430Adc12MultiChannel;
! EvaluatorC.Notify[unique(EVALUATOR_CLIENT)] -> TestMulti1;
!
! // Multi, RefVolt
! components new TestAdcMultiC(CONFIG_VREF,
! SUPPLY_VOLTAGE_HALF_CHANNEL, REFERENCE_VREFplus_AVss) as TestMulti2,
! new Msp430Adc12ClientAutoRVGC() as Wrapper5;
!
! TestMulti2 -> MainC.Boot;
! TestMulti2.Resource -> Wrapper5;
! TestMulti2.MultiChannel -> Wrapper5.Msp430Adc12MultiChannel;
! EvaluatorC.Notify[unique(EVALUATOR_CLIENT)] -> TestMulti2;
! Wrapper5.AdcConfigure -> TestMulti2;
}
- Previous message: [Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/msp430/adc12
Msp430Adc12ConfAlertC.nc, NONE,
1.1 Msp430Adc12ClientAutoRVGC.nc, 1.5,
1.6 Msp430Adc12ClientAutoDMA_RVGC.nc, 1.5, 1.6
- Next message: [Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/msp430/adc12
Msp430Adc12.h, 1.4, 1.5 Msp430Adc12ImplP.nc, 1.4,
1.5 Msp430Adc12P.nc, 1.4, 1.5 README.txt, 1.5, 1.6
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-2-commits
mailing list