[Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/imote2/tos/sensorboards/BasicSensorboard
BasicSensorboardAccelDataC.nc, NONE,
1.1 BasicSensorboardAccelDataM.nc, NONE,
1.1 BasicSensorboardC.nc, NONE, 1.1 BasicSensorboardDSPM.nc,
NONE, 1.1 BasicSensorboardManagerM.nc, NONE, 1.1 config.h,
NONE, 1.1 sampleHeader.h, NONE, 1.1 sensorboard.h, NONE, 1.1
Robbie Adler
radler at users.sourceforge.net
Wed Oct 25 08:03:53 PDT 2006
- Previous message: [Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/imote2/tos/include
- New directory
- Next message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/imote2/tos/sensorboards/Framework
BoardManager.nc, NONE, 1.1 BufferManagementDispatchM.nc, NONE,
1.1 ChannelManager.nc, NONE, 1.1 ChannelManagerM.nc, NONE,
1.1 channelParams.h, NONE, 1.1 ChannelParamsManager.nc, NONE,
1.1 ChannelParamsManagerM.nc, NONE, 1.1 DSPManager.nc, NONE,
1.1 frameworkconfig.h, NONE, 1.1 postprocessingFunctions.h,
NONE, 1.1 SensorboardC.nc, NONE, 1.1 SensorboardM.nc, NONE,
1.1 SensorData.nc, NONE, 1.1 SensorDataInfo.nc, NONE,
1.1 sensorTypes.h, NONE, 1.1 triggerFunctions.h, NONE,
1.1 TriggerManager.nc, NONE, 1.1 TriggerManagerM.nc, NONE,
1.1 triggerOps.h, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-1.x/contrib/imote2/tos/sensorboards/BasicSensorboard
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv27317/sensorboards/BasicSensorboard
Added Files:
BasicSensorboardAccelDataC.nc BasicSensorboardAccelDataM.nc
BasicSensorboardC.nc BasicSensorboardDSPM.nc
BasicSensorboardManagerM.nc config.h sampleHeader.h
sensorboard.h
Log Message:
initial release of driver framework and basicsensorboard driver
--- NEW FILE: BasicSensorboardAccelDataC.nc ---
/**
*
*@author Robbie Adler
*
**/
configuration BasicSensorboardAccelDataC{
provides {
// interface DSPManager;
interface SensorData;
interface StdControl;
}
}
implementation {
components BasicSensorboardAccelDataM as Data,
PXA27XGPIOIntC,
DVFSC,
// NoDSPM as DSPM,
SSP1C as SSPC;
SensorData = Data.SensorData;
StdControl = Data.StdControl;
Data.DVFS -> DVFSC;
Data.SSP ->SSPC.SSP;
Data.RawData -> SSPC.BulkTxRx;
Data.RDYInterrupt -> PXA27XGPIOIntC.PXA27XGPIOInt[96];
}
--- NEW FILE: BasicSensorboardAccelDataM.nc ---
module BasicSensorboardAccelDataM{
provides {
interface StdControl;
interface SensorData;
}
uses {
interface SSP;
interface BulkTxRx as RawData;
interface PXA27XGPIOInt as RDYInterrupt;
interface DVFS;
}
}
implementation {
#include "UOM.h"
#define ACCEL_CMD_BLOCK_SIZE 1
#define SPEED 0
typedef uint8_t AccelCmd_t[2];
AccelCmd_t AccelInitCmds[] = {{0x00, 0xA7},
{0x00, 0x96},
{0x00, 0x97},
{0x00, 0x98},
{0x00, 0x99},
{0x00, 0x9A},
{0x00, 0x9B},
{0xC7 | (SPEED <<4) , 0x20},
{0x04, 0x21}};
//read out all of the accel data
AccelCmd_t AccelReadCmds[] = {{0x00, 0xA8}, //XLow
{0x00, 0xA9}, //XHigh
{0x00, 0xAA}, //YLow
{0x00, 0xAB}, //YHigh
{0x00, 0xAC}, //ZLow
{0x00, 0xAD}};//ZHigh
uint16_t *gAccelRxBuffer = NULL;
uint16_t gAccelRxNumBytes = 0;
uint16_t gAccelRxBufferPos = 0;
BulkTxRxBuffer_t gBulkTxRxBuffer;
int32_t gXTotal=0, gYTotal=0, gZTotal=0;
uint32_t gTotalSamples = 0;
norace int16_t gCurrentXVal, gCurrentYVal;
norace uint8_t gScratchPad;
uint8_t gPrivateRxBuffer[32] __attribute__((aligned(32)));
norace uint8_t gAccelInitState = 0;
norace uint8_t gAccelReadState = 0;
norace bool gAccelInitDone = FALSE;
norace bool gAccelReadDone = TRUE;
uint8_t gTotalInitCommands = sizeof(AccelInitCmds)/sizeof(AccelCmd_t);
uint8_t gTotalReadCommands = sizeof(AccelReadCmds)/sizeof(AccelCmd_t);
void AccelInit();
void AccelRead();
command result_t StdControl.init() {
trace(DBG_USR1,"AccelDataM.StdControl.init()\r\n");
GPIO_SET_ALT_FUNC(96,0,GPIO_IN);
call RDYInterrupt.enable(TOSH_RISING_EDGE);
call SSP.setMasterSCLK(TRUE);
call SSP.setMasterSFRM(TRUE);
call SSP.setSSPFormat(SSP_SPI);
call SSP.setDataWidth(SSP_16bits);
call SSP.enableInvertedSFRM(FALSE);
call SSP.enableSPIClkHigh(TRUE);
call SSP.shiftSPIClk(TRUE);
call SSP.setRxFifoLevel(SSP_8Samples);
call SSP.setTxFifoLevel(SSP_8Samples);
call SSP.setClkRate(1);
call SSP.setClkMode(SSP_normalmode);
atomic{
gAccelRxBuffer = NULL;
gAccelRxNumBytes = 0;
gAccelRxBufferPos = 0;
}
return SUCCESS;
}
command result_t StdControl.start() {
if(gAccelRxBuffer!= NULL){
trace(DBG_USR1,"AccelDataM.StdControl.start()...changing clk to 104M\r\n");
call DVFS.SwitchCoreFreq(104,104);
call RDYInterrupt.enable(TOSH_RISING_EDGE);
AccelInit();
return SUCCESS;
}
else{
return FAIL;
}
}
command result_t StdControl.stop() {
trace(DBG_USR1,"AccelDataM.StdControl.stop()...changing clk to 13M\r\n");
call RDYInterrupt.disable();
// call DVFS.SwitchCoreFreq(13,13);
return SUCCESS;
}
command result_t SensorData.getSensorData(uint8_t *RxBuffer, uint32_t NumSamples){
trace(DBG_USR1,"AccelData: getting %d samples into buffer %#x\r\n",NumSamples, (uint32_t)RxBuffer);
atomic{
gAccelRxBuffer=RxBuffer;
gAccelRxNumBytes=NumSamples*6;
gAccelRxBufferPos = 0;
}
return SUCCESS;
}
command result_t SensorData.getOutputUOM(uint8_t *UOM) {
if(UOM){
*UOM = UOM_tfromString("gs");
return SUCCESS;
}
else{
return FAIL;
}
}
command result_t SensorData.setSensorType(uint32_t sensorType) {
return SUCCESS;
}
command result_t SensorData.setSamplingRate(uint32_t requestedSamplingRate, uint32_t *actualSamplingRate){
if(actualSamplingRate){
*actualSamplingRate = MAX_SAMPLING_RATE;
return SUCCESS;
}
return FAIL;
}
command result_t SensorData.setSampleWidth(uint8_t requestedSampleWidth){
if(requestedSampleWidth == 6){
return SUCCESS;
}
return FAIL;
}
void AccelInit(){
trace(DBG_USR1,"AccelData: initializing accelerometer\r\n");
atomic{
gAccelInitState = 0;
gAccelInitDone = FALSE;
gXTotal = 0;
gYTotal = 0;
gZTotal = 0;
gTotalSamples = 0;
gBulkTxRxBuffer.RxBuffer = gPrivateRxBuffer;
gBulkTxRxBuffer.TxBuffer = AccelInitCmds[gAccelInitState];
}
if(call RawData.BulkTxRx(&gBulkTxRxBuffer, sizeof(AccelCmd_t))==FAIL){
trace(DBG_USR1,"BulkTransmit failed\r\n");
}
}
void AccelRead(){
atomic{
gAccelReadState = 0;
gAccelReadDone = FALSE;
gBulkTxRxBuffer.RxBuffer = gPrivateRxBuffer;
gBulkTxRxBuffer.TxBuffer = AccelReadCmds[gAccelReadState];
}
if(call RawData.BulkTxRx(&gBulkTxRxBuffer, sizeof(AccelCmd_t)* ACCEL_CMD_BLOCK_SIZE)==FAIL){
trace(DBG_USR1,"BulkTransmit failed\r\n");
}
}
task void AccelReadTask(){
if(gAccelInitDone){
AccelRead();
}
}
async event void RDYInterrupt.fired(){
call RDYInterrupt.clear();
if(gAccelInitDone){
AccelRead();
}
}
async event uint8_t *RawData.BulkReceiveDone(uint8_t *RxBuffer, uint16_t NumBytes){
return NULL;
}
task void signalBulkTransmitFail(){
trace(DBG_USR1,"BulkTransmit failed\r\n");
}
async event uint8_t *RawData.BulkTransmitDone(uint8_t *TxBuffer, uint16_t NumBytes){
if(gAccelInitDone == FALSE){
gAccelInitState++;
if(gAccelInitState == gTotalInitCommands){
gAccelInitDone = TRUE;
}
else{
return AccelInitCmds[gAccelInitState];
}
}
else if(gAccelReadDone == FALSE){
gAccelReadState++;
if(gAccelReadState == gTotalReadCommands){
gAccelReadDone = TRUE;
}else{
return AccelReadCmds[gAccelReadState];
}
}
return NULL;
}
async event BulkTxRxBuffer_t *RawData.BulkTxRxDone(BulkTxRxBuffer_t *TxRxBuffer, uint16_t NumBytes){
if(gAccelInitDone == FALSE){
gAccelInitState++;
if(gAccelInitState == gTotalInitCommands){
gAccelInitDone = TRUE;
post AccelReadTask();
}
else{
TxRxBuffer->TxBuffer = AccelInitCmds[gAccelInitState];
return TxRxBuffer;
}
}
else if(gAccelReadDone == FALSE){
switch(gAccelReadState){
case 0:
gScratchPad = gPrivateRxBuffer[0];
break;
case 1:
gCurrentXVal = (int16_t)((gPrivateRxBuffer[0] << 8) | gScratchPad);
break;
case 2:
gScratchPad = gPrivateRxBuffer[0];
break;
case 3:
gCurrentYVal = (int16_t)((gPrivateRxBuffer[0] << 8) | gScratchPad);
break;
case 4:
gScratchPad = gPrivateRxBuffer[0];
break;
case 5:
atomic{
if(gAccelRxBuffer){
gAccelRxBuffer[gAccelRxBufferPos] = gCurrentXVal;
gAccelRxBuffer[gAccelRxBufferPos+1] = gCurrentYVal;
gAccelRxBuffer[gAccelRxBufferPos+2] = (int16_t)((gPrivateRxBuffer[0] << 8) | gScratchPad);
gAccelRxBufferPos+=3;
}
}
if((gAccelRxBufferPos*2) >= gAccelRxNumBytes){
//we're done
if((gAccelRxBuffer = (uint16_t *) signal SensorData.getSensorDataDone((uint8_t *)gAccelRxBuffer, gAccelRxNumBytes/6, OSCR0, 1.0, 0.0)) != NULL){
gAccelRxBufferPos = 0;
}
else{
call StdControl.stop();
}
}
break;
default:
//??
}
gAccelReadState+=ACCEL_CMD_BLOCK_SIZE;
if(gAccelReadState == gTotalReadCommands){
gAccelReadDone = TRUE;
}else{
TxRxBuffer->TxBuffer = AccelReadCmds[gAccelReadState];
return TxRxBuffer;
}
}
// post signalEnableCmdDone();
return NULL;
}
}
--- NEW FILE: BasicSensorboardC.nc ---
/**
*
*@author Robbie Adler
*
**/
configuration BasicSensorboardC{
provides {
interface StdControl;
interface GenericSampling;
}
uses{
interface BufferManagement;
interface WriteData;
}
}
implementation {
components SensorboardC,
BasicSensorboardAccelDataC as DataChan1,
//BasicSensorboardADCDataC as DataChan2,
PMICC,
BasicSensorboardManagerM as BoardManagerM;
StdControl = SensorboardC;
GenericSampling = SensorboardC;
BufferManagement = SensorboardC;
WriteData = SensorboardC;
SensorboardC.BoardManager -> BoardManagerM;
BoardManagerM.AccelDataControl -> DataChan1;
BoardManagerM.PMIC -> PMICC;
//data channel components get wired into the parameterized
//SensorData interface instance that corresponds to their
//data channel #. Typically, SensorData[0] will be wired into
//a dummyData Component, but this is usage defined.
SensorboardC.SensorData[1] -> DataChan1;
}
--- NEW FILE: BasicSensorboardDSPM.nc ---
module BasicSensorboardDSPM{
provides {
interface StdControl;
interface BulkTxRx as ProcessedData;
interface DSPManager;
}
uses {
interface SSP;
interface BulkTxRx as AccelData;
interface PXA27XGPIOInt as RDYInterrupt;
}
}
implementation {
command result_t StdControl.init() {
return SUCCESS;
}
command result_t StdControl.start() {
return SUCCESS;
}
command result_t StdControl.stop() {
return SUCCESS;
}
command result_t ProcessedData.BulkTxRx(BulkTxRxBuffer_t *TxRxBuffer, uint16_t NumBytes){
return FAIL;
}
command result_t ProcessedData.BulkTransmit(uint8_t *TxBuffer, uint16_t NumBytes){
return FAIL;
}
command result_t ProcessedData.BulkReceive(uint8_t *RxBuffer, uint16_t NumBytes){
return FAIL;
}
async event uint8_t *AccelData.BulkReceiveDone(uint8_t *RxBuffer, uint16_t NumBytes){
return NULL;
}
async event uint8_t *AccelData.BulkTransmitDone(uint8_t *TxBuffer, uint16_t NumBytes){
return NULL;
}
async event BulkTxRxBuffer_t *AccelData.BulkTxRxDone(BulkTxRxBuffer_t *TxRxBuffer, uint16_t NumBytes){
return NULL;
}
}
--- NEW FILE: BasicSensorboardManagerM.nc ---
/*****
*
* This Module provides the basic sensorobard specific implementation of the BoardManager interface
*
*
*
*
*******/
module BasicSensorboardManagerM{
provides{
interface BoardManager;
}
uses{
interface StdControl as AccelDataControl;
interface PMIC;
}
}
implementation{
#include "pmic.h"
command result_t BoardManager.enableChannelsToBeSampled(uint8_t numChannels, uint8_t *channelList){
int i;
for(i=0;i<numChannels;i++){
switch(channelList[i]){
case 1: //this is the accelerometer
call AccelDataControl.init();
break;
default:
break;
}
}
return SUCCESS;
}
command result_t BoardManager.startDataChannels(uint8_t numChannels, uint8_t *channelList){
int i;
//list of channels here are data channels
call PMIC.enableSBVoltage_High(FALSE, LDO_TRIM_2P8);
TOSH_uwait(6000); //wait 1 ms
call PMIC.enableSBVoltage_High(TRUE, LDO_TRIM_2P8);
for(i=0;i<numChannels;i++){
switch(channelList[i]){
case 1: //this is the accelerometer
call AccelDataControl.start();
break;
default:
break;
}
}
return SUCCESS;
}
}
--- NEW FILE: config.h ---
#ifndef __CONFIG_H__
#define __CONFIG_H__
//ONLY CONSTANTS MAY GO IN HERE!!!!
//total number of channels that the board exposes...be sure to include a "Fake" data channel if one exists for your board
#define TOTAL_CHANNELS (3)
//total number of data interfaces that this board utilizes for sampling
//each data interface is interlocked such that once sampling has been started
//on a data interface or a member of its simultaneous sampling group, another sampling instance may not be started until
//the current one is finished.
#define TOTAL_DATA_CHANNELS 3
//#define DOCHUNKING 1
#define CHUNKSIZE (100) //in samples
//#define DOPRETRIGGER
#define BLUSH_TRIGGER
#endif //__CONFIG_H__
--- NEW FILE: sampleHeader.h ---
#ifndef __SAMPLEHEADER_H__
#define __SAMPLEHEADER_H__
typedef struct {
uint8_t logicalNodeId; /* Intel logical nodeId, mote generating sample*/
uint8_t channelId; /* channelId generating the sample. This is VirtualChannel */
uint8_t acquisitionNum; /* Ordinal # of the acquisition for the query: e.g.1st, 2nd, 3rd */
uint8_t gSEFilterType; /* filler for header due to 32 bit boundary */
uint8_t sensorType; /* sensorType - Robbie creating enum */
uint8_t sampleWidth; /* bit width of sample data used for parsing sample body */
uint16_t queryGroupId; /* UniqueId of the query group being satisfied by this sample record */
uint8_t acquisitionCount; /* Total # of acquisitions needed to satisfy the query group */
uint8_t desiredUOM; /* Unit of Measure the user wants. See EngineeringUnits.h */
uint8_t outputUOM; /* Unit of Measure of the data on this sample record. See EngineeringUnits.h */
uint8_t engineeringUOM; /* Native UOM the sensor takes its readings in. See EngineeringUnits.h */
float conversionVal; /* Conversion of volts/EU to convert voltage reading the EU for the sensor */
float sensorZero; /* Zero stop of the sensor. */
uint32_t samplingRate; /* Rate at which samples are taken */
uint32_t numSamples; /* numSamples in this chunk */
uint32_t function; /* post processing function applied to data. Robbie creating function bitmap */
uint64_t microSecTimeStamp; /* micro-second accurate time stamp using time sync*/
uint32_t wallClockTimeStamp; /* second accurate wall clock stamp */
float ADCScale; /* Scaling used for Analog to Digital conversion */
float ADCOffset; /* Offset used for Analog to Digital conversion */
uint32_t sequenceID; /* unique number identifying the capture */
uint32_t sampleOffset; /* The offset of the 1st sample of this block within the total number of samples */
uint32_t totalSamples; /* total number of samples in an acquisition */
} sampleHeader_t __attribute__((packed, aligned(32)));
#endif //__SAMPLEHEADER_H__
--- NEW FILE: sensorboard.h ---
#ifndef __BASIC_SENSORBOARD_H__
#define __BASIC_SENSORBOARD_H__
/*
* Copyright (c) 2005 Intel Corporation
* All rights reserved.
*/
#include "config.h"
#include "channelParams.h"
#include "sensorTypes.h"
const char mySensorboardName[] = "BasicSensorboard";
#define MAX_SAMPLING_RATE (100000)
/*
* Supported sensor types
*/
#define SENSORTYPE1 ANALOG_SENSOR(SENSOR_ANALOG_ACCOUPLED | SENSOR_ANALOG_DCCOUPLED, \
SENSOR_ANALOG_VOLTAGE, \
SENSOR_ANALOG_SINGLEENDED | SENSOR_ANALOG_DIFFERENTIAL, \
SENSOR_ANALOG_RANGE_PLUS5V)
#define SENSORTYPE2 ANALOG_SENSOR(SENSOR_ANALOG_DCCOUPLED, \
SENSOR_ANALOG_CURRENT, \
SENSOR_ANALOG_DIFFERENTIAL, \
SENSOR_ANALOG_RANGE_PLUS5V)
#define SENSORTYPE3 DIGITAL_SENSOR(SENSOR_DIGITAL_3AXISACCEL)
//THE FIRST NUMBER MUST MATCH THE TOTAL NUMBER OF ELEMENTS IN THE SECOND INITIALIZER FOR ALL ELEMENTS TO BE RECOGNIZED!
//first element in the comondFeatureList for a sensor is the PhysicalChannel that it maps to
const supportedCommonFeatureList32_t channel0Sensors = {1,0,{0}};
const supportedCommonFeatureList32_t channel1Sensors = {1,1,{SENSORTYPE3}};
const supportedFeatureList8_t channel1Widths = {1,{48}};
const supportedCommonFeatureList32_t channel2Sensors = {2,2,{SENSORTYPE1,SENSORTYPE2}};
const supportedFeatureList32_t channel2Rates = {4,{100, 200, 400, 800}};
const supportedFeatureList8_t channel2Widths = {1,{16}};
const supportedFeatureList8_t simulChannelGroup0 = {1,{0}};
const supportedFeatureList8_t simulChannelGroup1 = {1,{1}};
const supportedFeatureList8_t simulChannelGroup2 = {1,{2}};
/*****************************
* Channel Capabilities Table
****************************/
const channelParam_t channelCapabilitiesTable[TOTAL_CHANNELS] = {
{MAX_SAMPLING_RATE, &channel0Sensors, NULL, NULL},
{MAX_SAMPLING_RATE, &channel1Sensors, NULL, &channel1Widths},
{MAX_SAMPLING_RATE, &channel2Sensors, &channel2Rates, &channel2Widths}};
/*****************************
* Data Channel Capabilities Table
****************************/
const dataChannelParam_t dataChannelCapabilitiesTable[TOTAL_DATA_CHANNELS] = {
{&simulChannelGroup0},
{&simulChannelGroup1},
{&simulChannelGroup2}};
#endif //__SENSORBOARD_H__
- Previous message: [Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/imote2/tos/include
- New directory
- Next message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/imote2/tos/sensorboards/Framework
BoardManager.nc, NONE, 1.1 BufferManagementDispatchM.nc, NONE,
1.1 ChannelManager.nc, NONE, 1.1 ChannelManagerM.nc, NONE,
1.1 channelParams.h, NONE, 1.1 ChannelParamsManager.nc, NONE,
1.1 ChannelParamsManagerM.nc, NONE, 1.1 DSPManager.nc, NONE,
1.1 frameworkconfig.h, NONE, 1.1 postprocessingFunctions.h,
NONE, 1.1 SensorboardC.nc, NONE, 1.1 SensorboardM.nc, NONE,
1.1 SensorData.nc, NONE, 1.1 SensorDataInfo.nc, NONE,
1.1 sensorTypes.h, NONE, 1.1 triggerFunctions.h, NONE,
1.1 TriggerManager.nc, NONE, 1.1 TriggerManagerM.nc, NONE,
1.1 triggerOps.h, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-contrib-commits
mailing list