[Tinyos-beta-commits] CVS: tinyos-1.x/beta/STM25P HALSTM25P.h, NONE, 1.1 HALSTM25P.nc, NONE, 1.1 HALSTM25PC.nc, NONE, 1.1 HALSTM25PM.nc, NONE, 1.1 Mount.nc, NONE, 1.1 Storage.h, NONE, 1.1 StorageManager.h, NONE, 1.1 StorageManagerC.nc, NONE, 1.1 StorageManagerM.nc, NONE, 1.1 StorageRemap.nc, NONE, 1.1 BlockRead.nc, 1.2, 1.3 BlockStorage.h, 1.1, 1.2 BlockStorageC.nc, 1.1, 1.2 BlockStorageM.nc, 1.4, 1.5 BlockWrite.nc, 1.1, 1.2 FlashWPC.nc, 1.1, 1.2 FlashWPM.nc, 1.2, 1.3 FlashVolume.h, 1.1, NONE FlashVolume.nc, 1.2, NONE FlashVolumeC.nc, 1.1, NONE FlashVolumeM.nc, 1.3, NONE STM25P.h, 1.2, NONE STM25P.nc, 1.3, NONE STM25PC.nc, 1.2, NONE STM25PM.nc, 1.4, NONE

Jonathan Hui jwhui at users.sourceforge.net
Tue Feb 8 16:46:12 PST 2005


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

Modified Files:
	BlockRead.nc BlockStorage.h BlockStorageC.nc BlockStorageM.nc 
	BlockWrite.nc FlashWPC.nc FlashWPM.nc 
Added Files:
	HALSTM25P.h HALSTM25P.nc HALSTM25PC.nc HALSTM25PM.nc Mount.nc 
	Storage.h StorageManager.h StorageManagerC.nc 
	StorageManagerM.nc StorageRemap.nc 
Removed Files:
	FlashVolume.h FlashVolume.nc FlashVolumeC.nc FlashVolumeM.nc 
	STM25P.h STM25P.nc STM25PC.nc STM25PM.nc 
Log Message:
- Changes to better match tep103. Still a work in
progress. BlockStorage HIL is nearly complete.

- Mount interface now included for initializing storage components.

- OSKI-style generic configuration for HIL.



--- NEW FILE: HALSTM25P.h ---
// $Id: HALSTM25P.h,v 1.1 2005/02/09 00:46:09 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>
 */

#ifndef __STM25P_H__
#define __STM25P_H__

enum {
  STM25P_PAGE_SIZE = 256
};

enum {
  STM25P_INVALID_SIG = 0xff,
};

enum {
  STM25P_ADDR_SIZE       = 3,
  STM25P_FR_DUMMY_BYTES  = 1,
  STM25P_RES_DUMMY_BYTES = 3,
};

enum {
                           // I, A, D, T, R
  STM25P_WREN      = 0x06, // 1, 0, 0, 0, 0
  STM25P_WRDI      = 0x04, // 1, 0, 0, 0, 0
  STM25P_RDSR      = 0x05, // 1, 0, 0, 0, 1
  STM25P_WRSR      = 0x01, // 1, 0, 0, 1, 0
  STM25P_READ      = 0x03, // 1, 3, 0, 0, N
  STM25P_FAST_READ = 0x0b, // 1, 3, 1, 0, N
  STM25P_PP        = 0x02, // 1, 3, 0, N, 0
  STM25P_SE        = 0xd8, // 1, 3, 0, 0, 0
  STM25P_BE        = 0xc7, // 1, 0, 0, 0, 0
  STM25P_DP        = 0xb9, // 1, 0, 0, 0, 0
  STM25P_RES       = 0xab, // 1, 0, 3, 0, 1
  STM25P_CRC       = 0xff, // not really an instruction
};

typedef uint8_t  stm25p_status_t;
typedef uint32_t stm25p_addr_t;
typedef uint8_t  stm25p_sig_t;

#endif

--- NEW FILE: HALSTM25P.nc ---
// $Id: HALSTM25P.nc,v 1.1 2005/02/09 00:46:09 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 HALSTM25P;

interface HALSTM25P {
  command result_t read(stm25p_addr_t addr, uint8_t* data, stm25p_addr_t len);
  event void readDone(result_t result);

  command result_t pageProgram(stm25p_addr_t addr, uint8_t* data, stm25p_addr_t len);
  event void pageProgramDone(result_t result);

  command result_t sectorErase(stm25p_addr_t addr);
  event void sectorEraseDone(result_t result);

  command result_t bulkErase();
  event void bulkEraseDone(result_t result);

  command result_t writeSR(uint8_t value);
  event void writeSRDone(result_t result);

  command result_t computeCrc(stm25p_addr_t addr, stm25p_addr_t len);
  event void computeCrcDone(result_t result, uint16_t crc);

  command stm25p_sig_t getSignature();
}

--- NEW FILE: HALSTM25PC.nc ---
// $Id: HALSTM25PC.nc,v 1.1 2005/02/09 00:46:09 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 crc;
includes HALSTM25P;

configuration HALSTM25PC {
  provides {
    interface StdControl;
    interface HALSTM25P[volume_t volume];
  }
  uses {
    interface StorageRemap[volume_t volume];
  }
}

implementation {
  components HALSTM25PM, HPLSTM25PC, NoLeds as Leds;

  StdControl = HALSTM25PM;
  StdControl = HPLSTM25PC;
  HALSTM25P = HALSTM25PM;
  StorageRemap = HALSTM25PM;

  HALSTM25PM.HPLSTM25P -> HPLSTM25PC;
  HALSTM25PM.Leds -> Leds;
}

--- NEW FILE: HALSTM25PM.nc ---
// $Id: HALSTM25PM.nc,v 1.1 2005/02/09 00:46:09 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 HALSTM25PM {
  provides {
    interface StdControl;
    interface HALSTM25P[volume_t volume];
  }
  uses {
    interface HPLSTM25P;
    interface Leds;
    interface StorageRemap[volume_t volume];
  }
}

implementation {
  
  enum {
    S_POWEROFF, // deep power-down state
    S_POWERON,  // awake state, no command in progress
  };

  stm25p_sig_t signature;
  uint16_t     crc;
  uint8_t      curCmd;
  volume_t     curVolume;

  void sendCmd(uint8_t cmd, stm25p_addr_t addr, uint8_t* data, stm25p_addr_t len);

  command result_t StdControl.init() {
    curCmd = S_POWEROFF;
    signature = STM25P_INVALID_SIG;
    return SUCCESS;
  }

  command result_t StdControl.start() { return SUCCESS; }
  command result_t StdControl.stop() { return SUCCESS; }

  void signalDone(result_t result) {
    uint8_t tmpCmd = curCmd;
    curCmd = S_POWERON;

    switch(tmpCmd) {
    case STM25P_READ: signal HALSTM25P.readDone[curVolume](result); break;
    case STM25P_PP: signal HALSTM25P.pageProgramDone[curVolume](result); break;
    case STM25P_SE: signal HALSTM25P.sectorEraseDone[curVolume](result); break;
    case STM25P_BE: signal HALSTM25P.bulkEraseDone[curVolume](result); break;
    case STM25P_WRSR: signal HALSTM25P.writeSRDone[curVolume](result); break;
    case STM25P_CRC: signal HALSTM25P.computeCrcDone[curVolume](result, crc); break;
    }
  }

  task void signalSuccess() { signalDone(SUCCESS); }
  task void signalFail() { signalDone(FAIL); }

  void checkPost(bool result) {
    if (result == FALSE)
      signalDone(FAIL);
  }

  bool isWriting() {
    uint8_t status;
    if (call HPLSTM25P.getBus() == FAIL)
      return TRUE;
    sendCmd(STM25P_RDSR, 0, &status, sizeof(status));
    call HPLSTM25P.releaseBus();
    return (status & 0x1) ? TRUE : FALSE;
  }

  // probably better to use a timer since write operations can take on
  // the order of seconds to complete
  task void checkWriteDone() {
    if (isWriting()) {
      checkPost(post checkWriteDone());
      return;
    }
    signalDone(SUCCESS);
  }

  void sendCmd(uint8_t cmd, stm25p_addr_t addr, uint8_t* data, stm25p_addr_t len) {

    uint8_t addrBytes[STM25P_ADDR_SIZE];
    stm25p_addr_t i;

    // start command
    switch(cmd) {
    case STM25P_CRC: call HPLSTM25P.beginCmd(STM25P_READ); break;
    default: call HPLSTM25P.beginCmd(cmd); break;
    }
    
    // address
    switch(cmd) {
    case STM25P_READ: case STM25P_FAST_READ: case STM25P_PP: 
    case STM25P_SE: case STM25P_CRC:
      for ( i = 0; i < STM25P_ADDR_SIZE; i++ )
	addrBytes[i] = (addr >> ((STM25P_ADDR_SIZE-1-i)*8)) & 0xff;
      call HPLSTM25P.txBuf(addrBytes, STM25P_ADDR_SIZE);
      break;
    }

    // dummy bytes
    switch(cmd) {
    case STM25P_FAST_READ:
      call HPLSTM25P.txBuf(addrBytes, STM25P_FR_DUMMY_BYTES);
      break;
    case STM25P_RES:
      call HPLSTM25P.txBuf(addrBytes, STM25P_RES_DUMMY_BYTES);
      break;
    }

    // data
    switch(cmd) {
    case STM25P_RDSR: case STM25P_READ: case STM25P_FAST_READ: case STM25P_RES:
      call HPLSTM25P.rxBuf(data, len);
      break;
    case STM25P_WRSR: case STM25P_PP:
      call HPLSTM25P.txBuf(data, len);
      break;
    case STM25P_CRC:
      call HPLSTM25P.computeCrc(&crc, len);
      break;
    }

    // end command
    call HPLSTM25P.endCmd();

  }

  void powerOff() {
    sendCmd(STM25P_DP, 0, NULL, 0);
    curCmd = S_POWEROFF;
  }

  void powerOn() {
    sendCmd(STM25P_RES, 0, &signature, sizeof(signature));
    TOSH_uwait(2); // wait at least 1.8us to power on
    curCmd = S_POWERON;
  }

  result_t newRequest(uint8_t cmd, volume_t volume, stm25p_addr_t addr, uint8_t* data, stm25p_addr_t len) {

    // make sure flash is powered on
    if (curCmd == S_POWEROFF)
      powerOn();
    // make sure nothing else is in progress
    else if (curCmd != S_POWERON)
      return FAIL;
    // make sure we can get the bus
    else if (call HPLSTM25P.getBus() == FAIL)
      return FAIL;

    addr = call StorageRemap.physicalAddr[volume](addr);

    curVolume = volume;
    
    curCmd = cmd;
    crc = 0;
    
    // enable writes if needed
    if (curCmd == STM25P_WRSR || curCmd == STM25P_PP 
	|| curCmd == STM25P_SE || curCmd == STM25P_BE)
      sendCmd(STM25P_WREN, 0, NULL, 0);
    
    // send command
    sendCmd(curCmd, addr, data, len);

    call HPLSTM25P.releaseBus();

    // setup check for write done
    if (curCmd == STM25P_WRSR || curCmd == STM25P_PP 
	|| curCmd == STM25P_SE || curCmd == STM25P_BE)
      checkPost(post checkWriteDone());
    else
      checkPost(post signalSuccess());

    return SUCCESS;

  }

  command result_t HALSTM25P.read[volume_t volume](stm25p_addr_t addr, uint8_t* data, stm25p_addr_t len) {
    return newRequest(STM25P_READ, volume, addr, data, len);
  }

  command result_t HALSTM25P.pageProgram[volume_t volume](stm25p_addr_t addr, uint8_t* data, stm25p_addr_t len) {
    return newRequest(STM25P_PP, volume, addr, data, len);
  }

  command result_t HALSTM25P.sectorErase[volume_t volume](stm25p_addr_t addr) {
    return newRequest(STM25P_SE, volume, addr, NULL, 0);
  }

  command result_t HALSTM25P.bulkErase[volume_t volume]() {
    return newRequest(STM25P_BE, volume, 0, NULL, 0);
  }

  command result_t HALSTM25P.writeSR[volume_t volume](uint8_t value) {
    return newRequest(STM25P_WRSR, volume, 0, &value, 1);
  }

  command result_t HALSTM25P.computeCrc[volume_t volume](stm25p_addr_t addr, stm25p_addr_t len) {
    return newRequest(STM25P_CRC, volume, addr, NULL, len);
  }

  command stm25p_sig_t HALSTM25P.getSignature[volume_t volume]() { 
    return signature; 
  }
  
  default event void HALSTM25P.readDone[volume_t volume](result_t result) { ; }
  default event void HALSTM25P.pageProgramDone[volume_t volume](result_t result) { ; }
  default event void HALSTM25P.sectorEraseDone[volume_t volume](result_t result) { ; }
  default event void HALSTM25P.bulkEraseDone[volume_t volume](result_t result) { ; }
  default event void HALSTM25P.writeSRDone[volume_t volume](result_t result) { ; }
  default event void HALSTM25P.computeCrcDone[volume_t volume](result_t result, uint16_t crcResult) { ; }

}

--- NEW FILE: Mount.nc ---

includes Storage;

interface Mount {
  command result_t mount(volume_id_t id);
  event void mountDone(storage_result_t result, volume_id_t id);
}

--- NEW FILE: Storage.h ---

#ifndef __STORAGE_H__
#define __STORAGE_H__

enum {
  STORAGE_OK,
};

typedef uint8_t volume_t;
typedef uint8_t volume_id_t;
typedef uint8_t storage_result_t;

#endif

--- NEW FILE: StorageManager.h ---
// $Id: StorageManager.h,v 1.1 2005/02/09 00:46:09 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>
 */

#ifndef __STORAGE_MANAGER_H__
#define __STORAGE_MANAGER_H__

#include "HALSTM25P.h"

enum {
  SM_INVALID_VOLUME = 0xff,
  SM_VOLUME_SIZE = ((stm25p_addr_t)0x10000),
  SM_GOLDEN_IMAGE = 0xf,
  SM_MAX_VOLUMES = 16,
  SM_INVALID_ADDR = ((stm25p_addr_t)0xffffffff),
};

#endif

--- NEW FILE: StorageManagerC.nc ---
// $Id: StorageManagerC.nc,v 1.1 2005/02/09 00:46:09 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 StorageManager;

configuration StorageManagerC {
  provides {
    interface HALSTM25P[volume_t volume];
    interface Mount[volume_t volume];
    interface StdControl;
    interface StorageRemap[volume_t volume];
  }
}

implementation {

  components HALSTM25PC, StorageManagerM;

  StdControl = StorageManagerM;
  StdControl = HALSTM25PC;
  HALSTM25P = HALSTM25PC;
  Mount = StorageManagerM;
  StorageRemap = StorageManagerM;

  HALSTM25PC.StorageRemap -> StorageManagerM;

}

--- NEW FILE: StorageManagerM.nc ---
// $Id: StorageManagerM.nc,v 1.1 2005/02/09 00:46:09 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 StorageManagerM {
  provides {
    interface Mount[volume_t volume];
    interface StdControl;
    interface StorageRemap[volume_t volume];
  }
}

implementation {

  enum {
    NUM_VOLUMES = uniqueCount("StorageManager"),
  };

  uint8_t volumeMap[NUM_VOLUMES];
  volume_t curVolume;

  command result_t StdControl.init() {

    uint8_t i;

    curVolume = SM_INVALID_VOLUME;

    for ( i = 0; i < NUM_VOLUMES; i++ )
      volumeMap[i] = SM_INVALID_VOLUME;

    return SUCCESS; 

  }

  command result_t StdControl.start() { 
    return SUCCESS; 
  }

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

  void signalMounted() {
    volume_id_t tmpVolume = curVolume;
    curVolume = SM_INVALID_VOLUME;
    signal Mount.mountDone[tmpVolume](STORAGE_OK, volumeMap[tmpVolume]);
  }

  task void mounted() {
    signalMounted();
  }

  command result_t Mount.mount[volume_t volume](volume_id_t volumeID) {

    if (curVolume != SM_INVALID_VOLUME || volumeID >= SM_MAX_VOLUMES)
      return FAIL;

    curVolume = volume;
    volumeMap[volume] = volumeID;
    
    post mounted();
    
    return SUCCESS;

  }
  
  command uint32_t StorageRemap.physicalAddr[volume_t _volume](uint32_t volumeAddr) {
    
    uint32_t base = (uint32_t)volumeMap[_volume]*SM_VOLUME_SIZE;
    
    if (volumeMap[_volume] == SM_INVALID_VOLUME || volumeAddr >= SM_VOLUME_SIZE)
      return SM_INVALID_ADDR;
    
    return base + volumeAddr;
    
  }

  default event void Mount.mountDone[volume_t volume](storage_result_t result, volume_id_t id) { ; }

}

--- NEW FILE: StorageRemap.nc ---
// $Id: StorageRemap.nc,v 1.1 2005/02/09 00:46:09 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>
 */

interface StorageRemap {
  command uint32_t physicalAddr(uint32_t volumeAddr);
}

Index: BlockRead.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/STM25P/BlockRead.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** BlockRead.nc	26 Nov 2004 20:09:46 -0000	1.2
--- BlockRead.nc	9 Feb 2005 00:46:09 -0000	1.3
***************
*** 30,39 ****
  interface BlockRead {
    command result_t read(block_addr_t addr, uint8_t* buf, block_addr_t len);
!   event   result_t readDone(result_t result);
  
    command result_t verify();
!   event   result_t verifyDone(result_t result);
  
    command result_t computeCrc(block_addr_t addr, block_addr_t len);
!   event result_t computeCrcDone(result_t result, uint16_t crc);
  }
--- 30,39 ----
  interface BlockRead {
    command result_t read(block_addr_t addr, uint8_t* buf, block_addr_t len);
!   event void readDone(result_t result);
  
    command result_t verify();
!   event void verifyDone(result_t result);
  
    command result_t computeCrc(block_addr_t addr, block_addr_t len);
!   event void computeCrcDone(result_t result, uint16_t crc);
  }

Index: BlockStorage.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/STM25P/BlockStorage.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** BlockStorage.h	20 Nov 2004 18:59:42 -0000	1.1
--- BlockStorage.h	9 Feb 2005 00:46:09 -0000	1.2
***************
*** 30,33 ****
--- 30,34 ----
  
  typedef uint16_t block_addr_t;
+ typedef uint8_t blockstorage_t;
  
  #endif

Index: BlockStorageC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/STM25P/BlockStorageC.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** BlockStorageC.nc	20 Nov 2004 18:59:42 -0000	1.1
--- BlockStorageC.nc	9 Feb 2005 00:46:09 -0000	1.2
***************
*** 27,37 ****
  
  includes BlockStorage;
- includes STM25P;
  
! configuration BlockStorageC {
    provides {
!     interface StdControl;
!     interface BlockWrite[uint8_t id];
!     interface BlockRead[uint8_t id];
    }
  }
--- 27,37 ----
  
  includes BlockStorage;
  
! generic configuration BlockStorageC() {
    provides {
!     interface Mount;
!     interface BlockRead;
!     interface BlockWrite;
!     interface StorageRemap;
    }
  }
***************
*** 39,57 ****
  implementation {
  
!   components
!     BlockStorageM,
!     FlashVolumeC,
!     STM25PC,
!     LedsC as Leds;
  
!   StdControl = BlockStorageM;
!   StdControl = FlashVolumeC;
!   StdControl = STM25PC;
!   BlockWrite = BlockStorageM;
!   BlockRead = BlockStorageM;
  
!   BlockStorageM.ActualFV -> FlashVolumeC.FlashVolume;
!   BlockStorageM.Leds -> Leds;
!   BlockStorageM.STM25P -> STM25PC;
  
  }
--- 39,58 ----
  implementation {
  
!   enum {
!     BLOCK_ID = unique("BlockStorage"),
!     VOLUME_ID = unique("StorageManager"),
!   };
  
!   components BlockStorageM, Main, StorageManagerC;
  
!   Mount = BlockStorageM.Mount[BLOCK_ID];
!   BlockRead = BlockStorageM.BlockRead[BLOCK_ID];
!   BlockWrite = BlockStorageM.BlockWrite[BLOCK_ID];
!   StorageRemap = StorageManagerC.StorageRemap[VOLUME_ID];
! 
!   Main.StdControl -> StorageManagerC;
! 
!   BlockStorageM.HALSTM25P[BLOCK_ID] -> StorageManagerC.HALSTM25P[VOLUME_ID];
!   BlockStorageM.ActualMount[BLOCK_ID] -> StorageManagerC.Mount[VOLUME_ID];
  
  }

Index: BlockStorageM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/STM25P/BlockStorageM.nc,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** BlockStorageM.nc	12 Jan 2005 01:35:06 -0000	1.4
--- BlockStorageM.nc	9 Feb 2005 00:46:09 -0000	1.5
***************
*** 28,39 ****
  module BlockStorageM {
    provides {
!     interface StdControl;
!     interface BlockWrite[uint8_t id];
!     interface BlockRead[uint8_t id];
    }
    uses {
!     interface FlashVolume as ActualFV[uint8_t id];
!     interface Leds;
!     interface STM25P;
    }
  }
--- 28,38 ----
  module BlockStorageM {
    provides {
!     interface Mount[blockstorage_t blockId];
!     interface BlockRead[blockstorage_t blockId];
!     interface BlockWrite[blockstorage_t blockId];
    }
    uses {
!     interface HALSTM25P[blockstorage_t blockId];
!     interface Mount as ActualMount[blockstorage_t blockId];
    }
  }
***************
*** 61,78 ****
    uint16_t crc;
  
!   command result_t StdControl.init() {
!     state = S_IDLE;
!     return SUCCESS;
!   }
! 
!   command result_t StdControl.start() {
!     return SUCCESS;
!   }
! 
!   command result_t StdControl.stop() {
!     return SUCCESS;
!   }
! 
!   result_t actualSignal(result_t result) {
  
      uint8_t tmpState = state;
--- 60,64 ----
    uint16_t crc;
  
!   void actualSignal(result_t result) {
  
      uint8_t tmpState = state;
***************
*** 81,92 ****
  
      switch(tmpState) {
!     case S_READ: return signal BlockRead.readDone[client](result);
!     case S_WRITE: return signal BlockWrite.writeDone[client](result);
!     case S_ERASE: return signal BlockWrite.eraseDone[client](result);
!     case S_CRC: return signal BlockRead.computeCrcDone[client](result, crc);
      }
  
-     return SUCCESS;
- 
    }
  
--- 67,76 ----
  
      switch(tmpState) {
!     case S_READ: signal BlockRead.readDone[client](result); break;
!     case S_WRITE: signal BlockWrite.writeDone[client](result); break;
!     case S_ERASE: signal BlockWrite.eraseDone[client](result); break;
!     case S_CRC: signal BlockRead.computeCrcDone[client](result, crc); break;
      }
  
    }
  
***************
*** 102,109 ****
    }
  
!   bool admitRequest(uint8_t id) {
      if (state != S_IDLE)
        return FALSE;
!     client = id;
      return TRUE;
    }
--- 86,101 ----
    }
  
!   command result_t Mount.mount[blockstorage_t blockId](volume_id_t id) {
!     return call ActualMount.mount[blockId](id);
!   }
! 
!   event void ActualMount.mountDone[blockstorage_t blockId](storage_result_t result, volume_id_t id) {
!     signal Mount.mountDone[blockId](result, id);
!   }
! 
!   bool admitRequest(blockstorage_t blockId) {
      if (state != S_IDLE)
        return FALSE;
!     client = blockId;
      return TRUE;
    }
***************
*** 121,129 ****
    }
  
!   command result_t BlockWrite.write[uint8_t id](block_addr_t addr, uint8_t* buf, block_addr_t len) {
! 
!     stm25p_addr_t physicalAddr;
  
!     if (admitRequest(id) == FAIL)
        return FAIL;
  
--- 113,119 ----
    }
  
!   command result_t BlockWrite.write[blockstorage_t blockId](block_addr_t addr, uint8_t* buf, block_addr_t len) {
  
!     if (admitRequest(blockId) == FAIL)
        return FAIL;
  
***************
*** 134,140 ****
      state = S_WRITE;
  
!     physicalAddr = call ActualFV.physicalAddr[client](addr);
! 
!     if (call STM25P.pageProgram(physicalAddr, buf, calcNumBytes()) == FAIL) {
        state = S_IDLE;
        return FAIL;
--- 124,128 ----
      state = S_WRITE;
  
!     if (call HALSTM25P.pageProgram[blockId](addr, buf, calcNumBytes()) == FAIL) {
        state = S_IDLE;
        return FAIL;
***************
*** 145,160 ****
    }
  
!   command result_t BlockWrite.erase[uint8_t id]() {
! 
!     stm25p_addr_t physicalAddr;
  
!     if (admitRequest(id) == FAIL)
        return FAIL;
  
      state = S_ERASE;
  
!     physicalAddr = call ActualFV.physicalAddr[client](0);
! 
!     if (call STM25P.sectorErase(physicalAddr) == FAIL) {
        state = S_IDLE;
        return FAIL;
--- 133,144 ----
    }
  
!   command result_t BlockWrite.erase[blockstorage_t blockId]() {
  
!     if (admitRequest(blockId) == FAIL)
        return FAIL;
  
      state = S_ERASE;
  
!     if (call HALSTM25P.sectorErase[blockId](0) == FAIL) {
        state = S_IDLE;
        return FAIL;
***************
*** 165,171 ****
    }
  
!   command result_t BlockWrite.commit[uint8_t id]() {
  
!     if (admitRequest(id) == FAIL)
        return FAIL;
  
--- 149,155 ----
    }
  
!   command result_t BlockWrite.commit[blockstorage_t blockId]() {
  
!     if (admitRequest(blockId) == FAIL)
        return FAIL;
  
***************
*** 178,193 ****
    }
  
!   command result_t BlockRead.read[uint8_t id](block_addr_t addr, uint8_t* buf, block_addr_t len) {
! 
!     stm25p_addr_t physicalAddr;
  
!     if (admitRequest(id) == FAIL)
        return FAIL;
  
      state = S_READ;
  
!     physicalAddr = call ActualFV.physicalAddr[client](addr);
! 
!     if (call STM25P.read(physicalAddr, buf, len) == FAIL) {
        state = S_IDLE;
        return FAIL;
--- 162,173 ----
    }
  
!   command result_t BlockRead.read[blockstorage_t blockId](block_addr_t addr, uint8_t* buf, block_addr_t len) {
  
!     if (admitRequest(blockId) == FAIL)
        return FAIL;
  
      state = S_READ;
  
!     if (call HALSTM25P.read[blockId](addr, buf, len) == FAIL) {
        state = S_IDLE;
        return FAIL;
***************
*** 198,203 ****
    }
  
!   command result_t BlockRead.verify[uint8_t id]() {
!     if (admitRequest(id) == FAIL)
        return FAIL;
      state = S_VERIFY;
--- 178,183 ----
    }
  
!   command result_t BlockRead.verify[blockstorage_t blockId]() {
!     if (admitRequest(blockId) == FAIL)
        return FAIL;
      state = S_VERIFY;
***************
*** 206,221 ****
    }
  
!   command result_t BlockRead.computeCrc[uint8_t id](block_addr_t addr, block_addr_t len) {
! 
!     stm25p_addr_t physicalAddr;
  
!     if (admitRequest(id) == FAIL)
        return FAIL;
  
      state = S_CRC;
  
!     physicalAddr = call ActualFV.physicalAddr[client](addr);
! 
!     if (call STM25P.computeCrc(physicalAddr, len) == FAIL) {
        state = S_IDLE;
        return FAIL;
--- 186,197 ----
    }
  
!   command result_t BlockRead.computeCrc[blockstorage_t blockId](block_addr_t addr, block_addr_t len) {
  
!     if (admitRequest(blockId) == FAIL)
        return FAIL;
  
      state = S_CRC;
  
!     if (call HALSTM25P.computeCrc[blockId](addr, len) == FAIL) {
        state = S_IDLE;
        return FAIL;
***************
*** 226,242 ****
    }
  
!   event result_t STM25P.readDone(result_t result) {
      signalDone(result);
-     return SUCCESS;
    }
  
!   event result_t STM25P.pageProgramDone(result_t result) {
  
      block_addr_t lastBytes = calcNumBytes();
-     stm25p_addr_t physicalAddr;
  
      if (bytesRemaining <= lastBytes) {
        signalDone(SUCCESS);
!       return SUCCESS;
      }
      else {
--- 202,216 ----
    }
  
!   event void HALSTM25P.readDone[blockstorage_t blockId](result_t result) {
      signalDone(result);
    }
  
!   event void HALSTM25P.pageProgramDone[blockstorage_t blockId](result_t result) {
  
      block_addr_t lastBytes = calcNumBytes();
  
      if (bytesRemaining <= lastBytes) {
        signalDone(SUCCESS);
!       return;
      }
      else {
***************
*** 246,283 ****
      }
  
!     physicalAddr = call ActualFV.physicalAddr[client](curAddr);
! 
!     if (call STM25P.pageProgram(physicalAddr, bufPtr, calcNumBytes()) == FAIL)
        signalDone(FAIL);
  
!     return SUCCESS;
  
    }
  
!   event result_t STM25P.sectorEraseDone(result_t result) {
      signalDone(result);
!     return SUCCESS;
    }
  
!   event result_t STM25P.bulkEraseDone(result_t result) { 
!     return SUCCESS; 
    }
  
!   event result_t STM25P.writeSRDone(result_t result) {
!     return SUCCESS;
    }
  
!   event result_t STM25P.computeCrcDone(result_t result, uint16_t crcResult) {
      crc = crcResult;
      signalDone(result);
!     return SUCCESS;
    }
  
!   default event result_t BlockWrite.writeDone[uint8_t id](result_t result) { return SUCCESS; }
!   default event result_t BlockWrite.eraseDone[uint8_t id](result_t result) { return SUCCESS; }
!   default event result_t BlockWrite.commitDone[uint8_t id](result_t result) { return SUCCESS; }
!   default event result_t BlockRead.readDone[uint8_t id](result_t result) { return SUCCESS; }
!   default event result_t BlockRead.verifyDone[uint8_t id](result_t result) { return SUCCESS; }
!   default event result_t BlockRead.computeCrcDone[uint8_t id](result_t result, uint16_t crcResult) { return SUCCESS; }
  
  }
--- 220,266 ----
      }
  
!     if (call HALSTM25P.pageProgram[blockId](curAddr, bufPtr, calcNumBytes()) == FAIL)
        signalDone(FAIL);
  
!     return;
  
    }
  
!   event void HALSTM25P.sectorEraseDone[blockstorage_t blockId](result_t result) {
      signalDone(result);
!     return;
    }
  
!   event void HALSTM25P.bulkEraseDone[blockstorage_t blockId](result_t result) { 
!     return;
    }
  
!   event void HALSTM25P.writeSRDone[blockstorage_t blockId](result_t result) {
!     return;
    }
  
!   event void HALSTM25P.computeCrcDone[blockstorage_t blockId](result_t result, uint16_t crcResult) {
      crc = crcResult;
      signalDone(result);
!     return;
    }
  
!   default command result_t ActualMount.mount[blockstorage_t blockId](volume_id_t id) { return FAIL; }
!   default command result_t HALSTM25P.read[blockstorage_t blockId](stm25p_addr_t addr, uint8_t* data, stm25p_addr_t len) { return FAIL; }
!   default command result_t HALSTM25P.pageProgram[blockstorage_t blockId](stm25p_addr_t addr, uint8_t* data, stm25p_addr_t len) { return FAIL; }
!   default command result_t HALSTM25P.sectorErase[blockstorage_t blockId](stm25p_addr_t addr) { return FAIL; }
!   default command result_t HALSTM25P.bulkErase[blockstorage_t blockId]() { return FAIL; }
!   default command result_t HALSTM25P.writeSR[blockstorage_t blockId](uint8_t value) { return FAIL; }
!   default command result_t HALSTM25P.computeCrc[blockstorage_t blockId](stm25p_addr_t addr, stm25p_addr_t len) { return FAIL; }
!   default command stm25p_sig_t HALSTM25P.getSignature[blockstorage_t blockId]() { return FAIL; }
! 
!   default event void BlockWrite.writeDone[blockstorage_t blockId](result_t result) { return; }
!   default event void BlockWrite.eraseDone[blockstorage_t blockId](result_t result) { return; }
!   default event void BlockWrite.commitDone[blockstorage_t blockId](result_t result) { return; }
!   default event void BlockRead.readDone[blockstorage_t blockId](result_t result) { return; }
!   default event void BlockRead.verifyDone[blockstorage_t blockId](result_t result) { return; }
!   default event void BlockRead.computeCrcDone[blockstorage_t blockId](result_t result, uint16_t crcResult) { return; }
! 
!   default event void Mount.mountDone[blockstorage_t blockId](storage_result_t result, volume_id_t id) { ; }
  
  }

Index: BlockWrite.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/STM25P/BlockWrite.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** BlockWrite.nc	20 Nov 2004 18:59:43 -0000	1.1
--- BlockWrite.nc	9 Feb 2005 00:46:09 -0000	1.2
***************
*** 30,39 ****
  interface BlockWrite {
    command result_t write(block_addr_t addr, uint8_t* buf, block_addr_t len);
!   event result_t writeDone(result_t result);
  
    command result_t erase();
!   event result_t eraseDone(result_t result);
  
    command result_t commit();
!   event result_t commitDone(result_t result);
  }
--- 30,39 ----
  interface BlockWrite {
    command result_t write(block_addr_t addr, uint8_t* buf, block_addr_t len);
!   event void writeDone(result_t result);
  
    command result_t erase();
!   event void eraseDone(result_t result);
  
    command result_t commit();
!   event void commitDone(result_t result);
  }

Index: FlashWPC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/STM25P/FlashWPC.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** FlashWPC.nc	22 Nov 2004 05:14:23 -0000	1.1
--- FlashWPC.nc	9 Feb 2005 00:46:09 -0000	1.2
***************
*** 9,18 ****
  implementation {
  
!   components FlashWPM, STM25PC;
  
    StdControl = FlashWPM;
    FlashWP = FlashWPM;
  
!   FlashWPM.STM25P -> STM25PC;
  
  }
--- 9,18 ----
  implementation {
  
!   components FlashWPM, HALSTM25PC;
  
    StdControl = FlashWPM;
    FlashWP = FlashWPM;
  
!   FlashWPM.HALSTM25P -> HALSTM25PC.HALSTM25P[0];
  
  }

Index: FlashWPM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/STM25P/FlashWPM.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** FlashWPM.nc	26 Nov 2004 20:09:46 -0000	1.2
--- FlashWPM.nc	9 Feb 2005 00:46:09 -0000	1.3
***************
*** 6,10 ****
    }
    uses {
!     interface STM25P;
    }
  }
--- 6,10 ----
    }
    uses {
!     interface HALSTM25P;
    }
  }
***************
*** 30,34 ****
    command result_t FlashWP.clrWP() {
      state = S_CLR;
!     if (call STM25P.writeSR(0x0) == FAIL) {
        state = S_IDLE;
        return FAIL;
--- 30,34 ----
    command result_t FlashWP.clrWP() {
      state = S_CLR;
!     if (call HALSTM25P.writeSR(0x0) == FAIL) {
        state = S_IDLE;
        return FAIL;
***************
*** 39,43 ****
    command result_t FlashWP.setWP() {
      state = S_SET;
!     if (call STM25P.writeSR(0x84) == FAIL) {
        state = S_IDLE;
        return FAIL;
--- 39,43 ----
    command result_t FlashWP.setWP() {
      state = S_SET;
!     if (call HALSTM25P.writeSR(0x84) == FAIL) {
        state = S_IDLE;
        return FAIL;
***************
*** 46,63 ****
    }
  
!   event result_t STM25P.writeSRDone(result_t result) {
      uint8_t tmpState = state;
      state = S_IDLE;
      switch(tmpState) {
!     case S_CLR: return signal FlashWP.clrWPDone(result);
!     case S_SET: return signal FlashWP.setWPDone(result);
      }
    }
  
!   event result_t STM25P.readDone(result_t result) { return SUCCESS; }
!   event result_t STM25P.pageProgramDone(result_t result) { return SUCCESS; }
!   event result_t STM25P.sectorEraseDone(result_t result) { return SUCCESS; }
!   event result_t STM25P.bulkEraseDone(result_t result) { return SUCCESS; }
!   event result_t STM25P.computeCrcDone(result_t result, uint16_t crc) { return SUCCESS; }
  
  }
--- 46,63 ----
    }
  
!   event void HALSTM25P.writeSRDone(result_t result) {
      uint8_t tmpState = state;
      state = S_IDLE;
      switch(tmpState) {
!     case S_CLR: signal FlashWP.clrWPDone(result); break;
!     case S_SET: signal FlashWP.setWPDone(result); break;
      }
    }
  
!   event void HALSTM25P.readDone(result_t result) { ; }
!   event void HALSTM25P.pageProgramDone(result_t result) { ; }
!   event void HALSTM25P.sectorEraseDone(result_t result) { ; }
!   event void HALSTM25P.bulkEraseDone(result_t result) { ; }
!   event void HALSTM25P.computeCrcDone(result_t result, uint16_t crc) { ; }
  
  }

--- FlashVolume.h DELETED ---

--- FlashVolume.nc DELETED ---

--- FlashVolumeC.nc DELETED ---

--- FlashVolumeM.nc DELETED ---

--- STM25P.h DELETED ---

--- STM25P.nc DELETED ---

--- STM25PC.nc DELETED ---

--- STM25PM.nc DELETED ---



More information about the Tinyos-beta-commits mailing list