[Tinyos-beta-commits] CVS: tinyos-1.x/beta/platform/telosb HPLSTM25PC.nc, NONE, 1.1 HPLSTM25PM.nc, NONE, 1.1

Jonathan Hui jwhui at users.sourceforge.net
Sat Nov 20 10:59:45 PST 2004


Update of /cvsroot/tinyos/tinyos-1.x/beta/platform/telosb
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31093/platform/telosb

Added Files:
	HPLSTM25PC.nc HPLSTM25PM.nc 
Log Message:
- Initial checkin of the storage stack for the STM25P family of flash
chips. 

- The new storage stack follows the HPL/HAL/HIL abstraction as
discussed in the TinyOS 1.2/2.x working group meetings. However, this
is not being checked into the 2.x branch since telosb uses the
STM25P80.

- Currently, only the BlockRead/Write interfaces of the HIL are
supported. LogRead/Write and ConfigRead/Write are in the works.

- The new storage interfaces are required for version 2 of Deluge.



--- NEW FILE: HPLSTM25PC.nc ---
// $Id: HPLSTM25PC.nc,v 1.1 2004/11/20 18:59:43 jwhui Exp $

/*									tab:4
 * "Copyright (c) 2000-2004 The Regents of the University  of California.  
 * All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose, without fee, and without written agreement is
 * hereby granted, provided that the above copyright notice, the following
 * two paragraphs and the author appear in all copies of this software.
 * 
 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
 * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
 * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
 */

/*
 * @author: Jonathan Hui <jwhui at cs.berkeley.edu>
 */

includes STM25P;

configuration HPLSTM25PC {
  provides {
    interface StdControl;
    interface HPLSTM25P;
  }
}

implementation {
  components 
    HPLSTM25PM, 
    BusArbitrationC, 
    HPLUSART0M;

  StdControl = HPLSTM25PM;
  HPLSTM25P = HPLSTM25PM;

  HPLSTM25PM.BusArbitration -> BusArbitrationC.BusArbitration[unique("BusArbitration")];
  HPLSTM25PM.USARTControl -> HPLUSART0M;
}

--- NEW FILE: HPLSTM25PM.nc ---
// $Id: HPLSTM25PM.nc,v 1.1 2004/11/20 18:59:43 jwhui Exp $

/*									tab:4
 * "Copyright (c) 2000-2004 The Regents of the University  of California.  
 * All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose, without fee, and without written agreement is
 * hereby granted, provided that the above copyright notice, the following
 * two paragraphs and the author appear in all copies of this software.
 * 
 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
 * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
 * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
 */

/*
 * @author: Jonathan Hui <jwhui at cs.berkeley.edu>
 */

module HPLSTM25PM {
  provides {
    interface StdControl;
    interface HPLSTM25P;
  }
  uses {
    interface BusArbitration;
    interface HPLUSARTControl as USARTControl;    
  }
}

implementation {

  command result_t StdControl.init() { 
    call USARTControl.setModeSPI();
    call USARTControl.disableRxIntr();
    call USARTControl.disableTxIntr();
    return SUCCESS; 
  }
  
  command result_t StdControl.start() { 
    call USARTControl.setModeSPI();
    call USARTControl.disableRxIntr();
    call USARTControl.disableTxIntr();
    return SUCCESS; 
  }

  command result_t StdControl.stop() { 
    call USARTControl.disableSPI();
    return SUCCESS; 
  }

  async command result_t HPLSTM25P.getBus() {
    return call BusArbitration.getBus();
  }
  
  async command result_t HPLSTM25P.releaseBus() {
    return call BusArbitration.releaseBus();
  }

  async command result_t HPLSTM25P.beginCmd(uint8_t cmd) {
    TOSH_CLR_FLASH_CS_PIN();
    call HPLSTM25P.unhold();
    // send command byte
    call USARTControl.tx(cmd);
    while(!(call USARTControl.isTxIntrPending()));
    return SUCCESS;
  }

  async command result_t HPLSTM25P.endCmd() {
    while(!(call USARTControl.isTxEmpty()));
    TOSH_SET_FLASH_CS_PIN();
    return SUCCESS;
  }

  async command result_t HPLSTM25P.hold() {
    TOSH_CLR_FLASH_HOLD_PIN();
    return SUCCESS;
  }

  async command result_t HPLSTM25P.unhold() {
    TOSH_SET_FLASH_HOLD_PIN();
    return SUCCESS;
  }

  async command result_t HPLSTM25P.txBuf(uint8_t* buf, stm25p_addr_t len) {

    stm25p_addr_t i;

    for ( i = 0; i < len; i++ ) {
      call USARTControl.tx(*buf++);
      while(!(call USARTControl.isTxIntrPending()));
    }

    return SUCCESS;

  }

  async command result_t HPLSTM25P.rxBuf(uint8_t* buf, stm25p_addr_t len) {

    stm25p_addr_t i;
    uint8_t     dummy;

    call USARTControl.rx(); // clear receive interrupt
    for ( i = 0; i < len; i++ ) {
      call HPLSTM25P.txBuf(&dummy, sizeof(dummy));
      while(!(call USARTControl.isRxIntrPending()));
      *buf++ = call USARTControl.rx();
    }

    return SUCCESS;
    
  }

  event result_t BusArbitration.busFree() { return SUCCESS; }

}



More information about the Tinyos-beta-commits mailing list