[Tinyos-2-commits] CVS: tinyos-2.x/tos/sensorboards/im2sb Tsl2561C.nc, NONE, 1.1.2.1 Tsl2561InternalC.nc, NONE, 1.1.2.1 Tsl2561InternalP.nc, NONE, 1.1.2.1

Philip Buonadonna philipb at users.sourceforge.net
Thu Jul 6 16:26:26 PDT 2006


Update of /cvsroot/tinyos/tinyos-2.x/tos/sensorboards/im2sb
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv10389

Added Files:
      Tag: tinyos-2_0_devel-BRANCH
	Tsl2561C.nc Tsl2561InternalC.nc Tsl2561InternalP.nc 
Log Message:
Added support for Taos TSL2561 on intel mote 2 sensorboard

--- NEW FILE: Tsl2561C.nc ---
/* $Id: Tsl2561C.nc,v 1.1.2.1 2006/07/06 23:26:24 philipb Exp $ */
/*
 * Copyright (c) 2005 Arch Rock Corporation 
 * 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 Arch Rock Corporation 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 ARCHED
 * ROCK OR ITS 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.
 */
/**
 *
 * @author Kaisen Lin
 * @author Phil Buonadonna
 */
#include "im2sb.h"

generic configuration Tsl2561C() {
  provides interface Read<uint16_t> as BroadbandPhoto;
  provides interface Read<uint16_t> as IRPhoto;
  provides interface HalTsl2561Advanced;
  provides interface SplitControl; // this is for power control?
  //provides interface Init;
}
implementation {
  components new HalTsl2561ReaderP();
  components HalTsl2561ControlP;

  BroadbandPhoto = HalTsl2561ReaderP.BroadbandPhoto;
  IRPhoto = HalTsl2561ReaderP.IRPhoto;

  enum { BB_KEY = unique("Tsl2561.Resource"),
	 IR_KEY = unique("Tsl2561.Resource"),
	 ADV_KEY = unique("Tsl2561.Resource"),
	 READER_ID = unique("Tsl2561.HplAccess"),
  };

  components Tsl2561InternalC;
  HalTsl2561ReaderP.BroadbandResource -> Tsl2561InternalC.Resource[BB_KEY];
  HalTsl2561ReaderP.IRResource -> Tsl2561InternalC.Resource[IR_KEY];
  HalTsl2561ControlP.Resource -> Tsl2561InternalC.Resource[ADV_KEY];

  HalTsl2561ReaderP.HplTSL256x -> Tsl2561InternalC.HplTSL256x[READER_ID];

  HalTsl2561Advanced = HalTsl2561ControlP.HalTsl2561Advanced;

  // for debugging
  SplitControl = Tsl2561InternalC;
}


--- NEW FILE: Tsl2561InternalC.nc ---
/* $Id: Tsl2561InternalC.nc,v 1.1.2.1 2006/07/06 23:26:24 philipb Exp $ */
/*
 * Copyright (c) 2005 Arch Rock Corporation 
 * 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 Arch Rock Corporation 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 ARCHED
 * ROCK OR ITS 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.
 */
/**
 *
 * @author Kaisen Lin
 * @author Phil Buonadonna
 */
#include "im2sb.h"

configuration Tsl2561InternalC {
  provides interface Resource[uint8_t id];
  provides interface HplTSL256x[uint8_t id];
  provides interface SplitControl;
}

implementation {
  enum { ADV_ID = unique("Tsl2561.HplAccess"),

  };

  components new FcfsArbiterC( "Tsl2561.Resource" ) as Arbiter;
  components MainC;
  Resource = Arbiter;
  MainC.SoftwareInit -> Arbiter;
  
  components new HplTSL2561LogicP(TSL2561_SLAVE_ADDR) as Logic;
  MainC.SoftwareInit -> Logic;

  components GeneralIOC;
  Logic.InterruptAlert -> GeneralIOC.GpioInterrupt[GPIO_TSL2561_LIGHT_INT];
  Logic.InterruptPin -> GeneralIOC.GeneralIO[GPIO_TSL2561_LIGHT_INT];

  components HalPXA27xI2CMasterC as I2CC;
  Logic.I2CPacket -> I2CC;

  components Tsl2561InternalP as Internal;
  HplTSL256x = Internal.HplTSL256x;
  Internal.ToHPLC -> Logic.HplTSL256x;

  SplitControl = Logic;

  components HplPXA27xGPIOC;
  I2CC.I2CSCL -> HplPXA27xGPIOC.HplPXA27xGPIOPin[I2C_SCL];
  I2CC.I2CSDA -> HplPXA27xGPIOC.HplPXA27xGPIOPin[I2C_SDA];

  components HalTsl2561ControlP;
  HalTsl2561ControlP.HplTSL256x -> Logic;
}

--- NEW FILE: Tsl2561InternalP.nc ---
/* $Id: Tsl2561InternalP.nc,v 1.1.2.1 2006/07/06 23:26:24 philipb Exp $ */
/*
 * Copyright (c) 2005 Arch Rock Corporation 
 * 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 Arch Rock Corporation 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 ARCHED
 * ROCK OR ITS 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.
 */
/**
 *
 * @author Kaisen Lin
 * @author Phil Buonadonna
 */
module Tsl2561InternalP {
  provides interface HplTSL256x[uint8_t id];
  uses interface HplTSL256x as ToHPLC;
}

implementation {
  uint8_t currentId;
  
  command error_t HplTSL256x.measureCh0[uint8_t id]() {
    currentId = id;
    return call ToHPLC.measureCh0();
  }
  command error_t HplTSL256x.measureCh1[uint8_t id]() {
    currentId = id;
    return call ToHPLC.measureCh1();
  }
  command error_t HplTSL256x.setCONTROL[uint8_t id](uint8_t val) {
    currentId = id;
    return call ToHPLC.setCONTROL(val);
  }
  command error_t HplTSL256x.setTIMING[uint8_t id](uint8_t val) {
    currentId = id;
    return call ToHPLC.setTIMING(val);
  }
  command error_t HplTSL256x.setTHRESHLOW[uint8_t id](uint16_t val) {
    currentId = id;
    return call ToHPLC.setTHRESHLOW(val);
  }
  command error_t HplTSL256x.setTHRESHHIGH[uint8_t id](uint16_t val) {
    currentId = id;
    return call ToHPLC.setTHRESHHIGH(val);
  }
  command error_t HplTSL256x.setINTERRUPT[uint8_t id](uint8_t val) {
    currentId = id;
    return call ToHPLC.setINTERRUPT(val);
  }
  command error_t HplTSL256x.getID[uint8_t id]() {
    currentId = id;
    return call ToHPLC.getID();
  }
  
  async event void ToHPLC.measureCh0Done(error_t result, uint16_t val) {
    signal HplTSL256x.measureCh0Done[currentId](result, val);
  }
  async event void ToHPLC.measureCh1Done(error_t result, uint16_t val) {
    signal HplTSL256x.measureCh1Done[currentId](result, val);
  }
  async event void ToHPLC.setCONTROLDone(error_t error) {
    signal HplTSL256x.setCONTROLDone[currentId](error);
  }
  async event void ToHPLC.setTIMINGDone(error_t error) {
    signal HplTSL256x.setTIMINGDone[currentId](error);
  }
  async event void ToHPLC.setTHRESHLOWDone(error_t error) {
    signal HplTSL256x.setTHRESHLOWDone[currentId](error);
  }
  async event void ToHPLC.setTHRESHHIGHDone(error_t error) {
    signal HplTSL256x.setTHRESHHIGHDone[currentId](error);
  }
  async event void ToHPLC.setINTERRUPTDone(error_t error) {
    signal HplTSL256x.setINTERRUPTDone[currentId](error);
  }
  async event void ToHPLC.getIDDone(error_t error, uint8_t idval) {
    signal HplTSL256x.getIDDone[currentId](error, idval);
  }
  async event void ToHPLC.alertThreshold() {
    signal HplTSL256x.alertThreshold[currentId]();
  }

  default async event void HplTSL256x.measureCh0Done[uint8_t id]( error_t error, uint16_t val ){ return; }
  default async event void HplTSL256x.measureCh1Done[uint8_t id]( error_t error, uint16_t val ){ return; }
  default async event void HplTSL256x.setCONTROLDone[uint8_t id]( error_t error ){ return; }
  default async event void HplTSL256x.setTIMINGDone[uint8_t id](error_t error){ return; }
  default async event void HplTSL256x.setTHRESHLOWDone[uint8_t id](error_t error){ return;} 
  default async event void HplTSL256x.setTHRESHHIGHDone[uint8_t id](error_t error){ return; }
  default async event void HplTSL256x.setINTERRUPTDone[uint8_t id](error_t error){ return;} 
  default async event void HplTSL256x.getIDDone[uint8_t id](error_t error, uint8_t idval){ return; }
  default async event void HplTSL256x.alertThreshold[uint8_t id](){ return; }
}



More information about the Tinyos-2-commits mailing list