[Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/rincon/apps/Blackbook5/media/avr
GenericCrcM.nc, NONE, 1.1 FlashBridgeC.nc, NONE,
1.1 FlashSettings.h, NONE, 1.1 FlashBridgeM.nc, NONE,
1.1 GenericCrcC.nc, NONE, 1.1 GenericCrc.nc, NONE,
1.1 readme.txt, NONE, 1.1
dmm
rincon at users.sourceforge.net
Thu Sep 28 10:32:14 PDT 2006
- Previous message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/rincon/apps/Blackbook5/media/msp430
FlashSettings.h, NONE, 1.1 GenericCrcC.nc, NONE,
1.1 GenericCrc.nc, NONE, 1.1 GenericCrcM.nc, NONE,
1.1 FlashBridgeC.nc, NONE, 1.1 readme.txt, NONE,
1.1 FlashBridgeM.nc, NONE, 1.1
- Next message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/rincon/apps/Blackbook5/apps/StandaloneFull
TestBlackbookFullM.nc, 1.1, 1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-1.x/contrib/rincon/apps/Blackbook5/media/avr
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv14770/contrib/rincon/apps/Blackbook5/media/avr
Added Files:
GenericCrcM.nc FlashBridgeC.nc FlashSettings.h FlashBridgeM.nc
GenericCrcC.nc GenericCrc.nc readme.txt
Log Message:
Updated to Blackbook v.5.2
--- NEW FILE: GenericCrcM.nc ---
/*
* Copyright (c) 2004-2006 Rincon Research Corporation.
* All rights reserved.
*
* Rincon Research will permit distribution and use by others subject to
* the restrictions of a licensing agreement which contains (among other things)
* the following restrictions:
*
* 1. No credit will be taken for the Work of others.
* 2. It will not be resold for a price in excess of reproduction and
* distribution costs.
* 3. Others are not restricted from copying it or using it except as
* set forward in the licensing agreement.
* 4. Commented source code of any modifications or additions will be
* made available to Rincon Research on the same terms.
* 5. This notice will remain intact and displayed prominently.
*
* Copies of the complete licensing agreement may be obtained by contacting
* Rincon Research, 101 N. Wilmot, Suite 101, Tucson, AZ 85711.
*
* There is no warranty with this product, either expressed or implied.
* Use at your own risk. Rincon Research is not liable or responsible for
* damage or loss incurred or resulting from the use or misuse of this software.
*/
/*
* Copyright (c) 2004-2006 Rincon Research Corporation.
* All rights reserved.
*
* Rincon Research will permit distribution and use by others subject to
* the restrictions of a licensing agreement which contains (among other things)
* the following restrictions:
*
* 1. No credit will be taken for the Work of others.
* 2. It will not be resold for a price in excess of reproduction and
* distribution costs.
* 3. Others are not restricted from copying it or using it except as
* set forward in the licensing agreement.
* 4. Commented source code of any modifications or additions will be
* made available to Rincon Research on the same terms.
* 5. This notice will remain intact and displayed prominently.
*
* Copies of the complete licensing agreement may be obtained by contacting
* Rincon Research, 101 N. Wilmot, Suite 101, Tucson, AZ 85711.
*
* There is no warranty with this product, either expressed or implied.
* Use at your own risk. Rincon Research is not liable or responsible for
* damage or loss incurred or resulting from the use or misuse of this software.
*/
/**
* GenericCrc configuration
* Uses the same CRC algorithm as BlockStorage.
* @author David Moss (dmm at rincon.com)
*/
includes crc;
module GenericCrcM {
provides {
interface GenericCrc;
}
}
implementation {
/**
* Calculate the CRC from a buffer of data
* of size len, starting with the crc given in
* startCrc. This uses the CRC algorithm found
* in /tos/crc.h.
*
* @param startCrc - the starting crc value
* @param *buf - the buffer of data to take a crc of
* @param len - the amount of data to calculate the crc for
* @return the crc.
*/
command uint16_t GenericCrc.crc16(uint16_t startCrc, void *buf, uint32_t len) {
uint8_t *buffer = (uint8_t *) buf;
for ( ; len > 0; len--) {
startCrc = crcByte(startCrc, *buffer++);
}
return startCrc;
}
}
--- NEW FILE: FlashBridgeC.nc ---
/*
* Copyright (c) 2004-2006 Rincon Research Corporation.
* All rights reserved.
*
* Rincon Research will permit distribution and use by others subject to
* the restrictions of a licensing agreement which contains (among other things)
* the following restrictions:
*
* 1. No credit will be taken for the Work of others.
* 2. It will not be resold for a price in excess of reproduction and
* distribution costs.
* 3. Others are not restricted from copying it or using it except as
* set forward in the licensing agreement.
* 4. Commented source code of any modifications or additions will be
* made available to Rincon Research on the same terms.
* 5. This notice will remain intact and displayed prominently.
*
* Copies of the complete licensing agreement may be obtained by contacting
* Rincon Research, 101 N. Wilmot, Suite 101, Tucson, AZ 85711.
*
* There is no warranty with this product, either expressed or implied.
* Use at your own risk. Rincon Research is not liable or responsible for
* damage or loss incurred or resulting from the use or misuse of this software.
*/
/**
* FlashBridge implementation for the MSP430 internal flash
* @author David Moss
*/
configuration FlashBridgeC {
provides {
interface FlashBridge[uint8_t id];
interface StdControl;
}
}
implementation {
components FlashBridgeM, GenericCrcC, StateC;
FlashBridge = FlashBridgeM;
StdControl = FlashBridgeM;
FlashBridgeM.GenericCrc -> GenericCrcC;
FlashBridgeM.State -> StateC.State[unique("State")];
}
--- NEW FILE: FlashSettings.h ---
/*
* Copyright (c) 2004-2006 Rincon Research Corporation.
* All rights reserved.
*
* Rincon Research will permit distribution and use by others subject to
* the restrictions of a licensing agreement which contains (among other things)
* the following restrictions:
*
* 1. No credit will be taken for the Work of others.
* 2. It will not be resold for a price in excess of reproduction and
* distribution costs.
* 3. Others are not restricted from copying it or using it except as
* set forward in the licensing agreement.
* 4. Commented source code of any modifications or additions will be
* made available to Rincon Research on the same terms.
* 5. This notice will remain intact and displayed prominently.
*
* Copies of the complete licensing agreement may be obtained by contacting
* Rincon Research, 101 N. Wilmot, Suite 101, Tucson, AZ 85711.
*
* There is no warranty with this product, either expressed or implied.
* Use at your own risk. Rincon Research is not liable or responsible for
* damage or loss incurred or resulting from the use or misuse of this software.
*/
/*
* Flash Information
* Internal AVR EEPROM
* 4096 bytes total
* Because this is an EEPROM, we do not need to erase before write.
* However, because we're abstracting it to act the same as other
* memories, FlashBridge will allow you to explicitly erase segments of the
* EEPROM. This will write 0xFF's to all the bytes in the segment.
* This is important because some apps expect to read 0xFF's to know
* if that area of memory is available to safely write.
*
* The erase unit size (segment length) below was simply chosen as
* a multiple of 4096.
*
*/
enum {
FLASH_SEGMENT_LENGTH = 0x80,
FLASH_TOTAL_SEGMENTS = 32,
FLASH_FILL_BYTE = 0xFF,
};
--- NEW FILE: FlashBridgeM.nc ---
/*
* Copyright (c) 2004-2006 Rincon Research Corporation.
* All rights reserved.
*
* Rincon Research will permit distribution and use by others subject to
* the restrictions of a licensing agreement which contains (among other things)
* the following restrictions:
*
* 1. No credit will be taken for the Work of others.
* 2. It will not be resold for a price in excess of reproduction and
* distribution costs.
* 3. Others are not restricted from copying it or using it except as
* set forward in the licensing agreement.
* 4. Commented source code of any modifications or additions will be
* made available to Rincon Research on the same terms.
* 5. This notice will remain intact and displayed prominently.
*
* Copies of the complete licensing agreement may be obtained by contacting
* Rincon Research, 101 N. Wilmot, Suite 101, Tucson, AZ 85711.
*
* There is no warranty with this product, either expressed or implied.
* Use at your own risk. Rincon Research is not liable or responsible for
* damage or loss incurred or resulting from the use or misuse of this software.
*/
/**
* FlashBridge implementation for the AVR internal flash
* Start address is 0x0
* End address is 0xFFF
*
* @author David Moss
*/
includes FlashSettings;
includes InternalFlash;
module FlashBridgeM {
provides {
interface FlashBridge[uint8_t id];
interface StdControl;
}
uses {
interface State;
interface GenericCrc;
}
}
implementation {
enum {
S_IDLE,
S_BUSY,
};
/***************** Tasks ****************/
task void checkReady();
/***************** StdControl Commands ****************/
command result_t StdControl.init() {
return SUCCESS;
}
command result_t StdControl.start() {
call State.forceState(S_BUSY);
post checkReady();
return SUCCESS;
}
command result_t StdControl.stop() {
return SUCCESS;
}
/***************** FlashBridge Commands ****************/
/**
* Read bytes from flash
* @param addr - the address to read from
* @param *buf - the buffer to read into
* @param len - the amount to read
* @return SUCCESS if the bytes will be read
*/
command result_t FlashBridge.read[uint8_t id](uint32_t addr, void *buf, uint32_t len) {
void *addressPtr = (uint16_t *) ((uint16_t) addr);
if(addr + len > FLASH_SEGMENT_LENGTH * FLASH_TOTAL_SEGMENTS) {
return FAIL;
}
if(!call State.requestState(S_BUSY)) {
return FAIL;
}
eeprom_read_block(buf, addressPtr, len);
while(!eeprom_is_ready());
call State.toIdle();
signal FlashBridge.readDone[id](addr, buf, len, SUCCESS);
return SUCCESS;
}
/**
* Write bytes to flash
* @param addr - the address to write to
* @param *buf - the buffer to write from
* @param len - the amount to write
* @return SUCCESS if the bytes will be written
*/
command result_t FlashBridge.write[uint8_t id](uint32_t addr, void *buf, uint32_t len) {
void *addressPtr = (uint16_t *) ((uint16_t) addr);
if(addr + len > FLASH_SEGMENT_LENGTH * FLASH_TOTAL_SEGMENTS) {
return FAIL;
}
if(!call State.requestState(S_BUSY)) {
return FAIL;
}
eeprom_write_block(buf, addressPtr, len);
while(!eeprom_is_ready());
call State.toIdle();
signal FlashBridge.writeDone[id](addr, buf, len, SUCCESS);
return SUCCESS;
}
/**
* Erase a segment in internal flash
*
* @param segment - the segment to erase, starting at 0
* @return SUCCESS if the segment will be erased
*/
command result_t FlashBridge.erase[uint8_t id](uint16_t segment) {
int i;
void *addressPtr;
if(segment > FLASH_TOTAL_SEGMENTS) {
return FAIL;
}
if(!call State.requestState(S_BUSY)) {
return FAIL;
}
addressPtr = (uint16_t *) ((uint16_t) (segment * FLASH_SEGMENT_LENGTH));
for(i = 0; i < FLASH_SEGMENT_LENGTH; i++) {
eeprom_write_byte(addressPtr, FLASH_FILL_BYTE);
addressPtr++;
}
while(!eeprom_is_ready());
call State.toIdle();
signal FlashBridge.eraseDone[id](segment, SUCCESS);
return SUCCESS;
}
/**
* Flush written data to flash. This only applies to some flash
* chips.
* @return SUCCESS if the flash will be flushed
*/
command result_t FlashBridge.flush[uint8_t id]() {
signal FlashBridge.flushDone[id](SUCCESS);
return SUCCESS;
}
/**
* Obtain the CRC of a chunk of data sitting on flash.
* @param addr - the address to start the CRC computation
* @param len - the amount of data to obtain the CRC for
* @return SUCCESS if the CRC will be computed.
*/
command result_t FlashBridge.crc[uint8_t id](uint32_t addr, uint32_t len) {
uint16_t runningCrc = 0;
void *addressPtr = (uint16_t *) ((uint16_t) addr);
int i;
uint8_t readByte;
if(addr + len > FLASH_SEGMENT_LENGTH * FLASH_TOTAL_SEGMENTS) {
return FAIL;
}
if(!call State.requestState(S_BUSY)) {
return FAIL;
}
for(i = 0; i < len; i++) {
readByte = eeprom_read_byte(addressPtr);
addressPtr++;
runningCrc = call GenericCrc.crc16(runningCrc, &readByte, sizeof(readByte));
}
while(!eeprom_is_ready());
call State.toIdle();
signal FlashBridge.crcDone[id](runningCrc, addr, len, SUCCESS);
return SUCCESS;
}
/***************** Tasks *****************/
task void checkReady() {
int i;
while(!eeprom_is_ready());
call State.toIdle();
for(i = 0; i < uniqueCount("FlashBridge"); i++) {
signal FlashBridge.ready[i](SUCCESS);
}
}
/***************** Defaults ****************/
default event void FlashBridge.readDone[uint8_t id](uint32_t addr, void *buf, uint32_t len, result_t result) {
}
default event void FlashBridge.writeDone[uint8_t id](uint32_t addr, void *buf, uint32_t len, result_t result) {
}
default event void FlashBridge.eraseDone[uint8_t id](uint16_t sector, result_t result) {
}
default event void FlashBridge.flushDone[uint8_t id](result_t result) {
}
default event void FlashBridge.crcDone[uint8_t id](uint16_t calculatedCrc, uint32_t addr, uint32_t len, result_t result) {
}
default event void FlashBridge.ready[uint8_t id](result_t result) {
}
}
--- NEW FILE: GenericCrcC.nc ---
/*
* Copyright (c) 2004-2006 Rincon Research Corporation.
* All rights reserved.
*
* Rincon Research will permit distribution and use by others subject to
* the restrictions of a licensing agreement which contains (among other things)
* the following restrictions:
*
* 1. No credit will be taken for the Work of others.
* 2. It will not be resold for a price in excess of reproduction and
* distribution costs.
* 3. Others are not restricted from copying it or using it except as
* set forward in the licensing agreement.
* 4. Commented source code of any modifications or additions will be
* made available to Rincon Research on the same terms.
* 5. This notice will remain intact and displayed prominently.
*
* Copies of the complete licensing agreement may be obtained by contacting
* Rincon Research, 101 N. Wilmot, Suite 101, Tucson, AZ 85711.
*
* There is no warranty with this product, either expressed or implied.
* Use at your own risk. Rincon Research is not liable or responsible for
* damage or loss incurred or resulting from the use or misuse of this software.
*/
/*
* Copyright (c) 2004-2006 Rincon Research Corporation.
* All rights reserved.
*
* Rincon Research will permit distribution and use by others subject to
* the restrictions of a licensing agreement which contains (among other things)
* the following restrictions:
*
* 1. No credit will be taken for the Work of others.
* 2. It will not be resold for a price in excess of reproduction and
* distribution costs.
* 3. Others are not restricted from copying it or using it except as
* set forward in the licensing agreement.
* 4. Commented source code of any modifications or additions will be
* made available to Rincon Research on the same terms.
* 5. This notice will remain intact and displayed prominently.
*
* Copies of the complete licensing agreement may be obtained by contacting
* Rincon Research, 101 N. Wilmot, Suite 101, Tucson, AZ 85711.
*
* There is no warranty with this product, either expressed or implied.
* Use at your own risk. Rincon Research is not liable or responsible for
* damage or loss incurred or resulting from the use or misuse of this software.
*/
/**
* GenericCrc configuration
* @author David Moss (dmm at rincon.com)
*/
configuration GenericCrcC {
provides {
interface GenericCrc;
}
}
implementation {
components GenericCrcM;
GenericCrc = GenericCrcM;
}
--- NEW FILE: GenericCrc.nc ---
/*
* Copyright (c) 2004-2006 Rincon Research Corporation.
* All rights reserved.
*
* Rincon Research will permit distribution and use by others subject to
* the restrictions of a licensing agreement which contains (among other things)
* the following restrictions:
*
* 1. No credit will be taken for the Work of others.
* 2. It will not be resold for a price in excess of reproduction and
* distribution costs.
* 3. Others are not restricted from copying it or using it except as
* set forward in the licensing agreement.
* 4. Commented source code of any modifications or additions will be
* made available to Rincon Research on the same terms.
* 5. This notice will remain intact and displayed prominently.
*
* Copies of the complete licensing agreement may be obtained by contacting
* Rincon Research, 101 N. Wilmot, Suite 101, Tucson, AZ 85711.
*
* There is no warranty with this product, either expressed or implied.
* Use at your own risk. Rincon Research is not liable or responsible for
* damage or loss incurred or resulting from the use or misuse of this software.
*/
/**
* GenericCrc Interface
* Uses the same CRC algorithm as BlockStorage.
* @author David Moss (dmm at rincon.com)
*/
interface GenericCrc {
/**
* Calculate the CRC from a buffer of data
* of size len, starting with the crc given in
* startCrc. This uses the CRC algorithm found
* in /tos/crc.h.
*
* @param startCrc - the starting crc value
* @param *buf - the buffer of data to take a crc of
* @param len - the amount of data to calculate the crc for
* @return the crc.
*/
command uint16_t crc16(uint16_t startCrc, void *buf, uint32_t len);
}
--- NEW FILE: readme.txt ---
The internal memory on the avr is an EEPROM, meaning you can write
over the top of addresses that have already been written. The memory
is erased every time you install a new application on the mote in the
internal flash.
If you are strictly implementing software for the avr, then you don't have
to erase segments before writing them. Erase, in this case, will simply write
out 0xFF fill bytes to the choosen segment. The erase function is useful
to maintain application compatibility across platforms.
Flush is not implemented either, but it is on other platforms. If the avr
is the only platform you plan on running your application on, then there
is no need to call flush(). Otherwise, calling flush() after you have
written data will support cross-platform compatibility.
This FlashBridge interface uses the pre-defined EEPROM functions
provided in /usr/avr/includes/avr. This will work on many other AVR
platforms besides just the ATmega128.
@author David Moss
- Previous message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/rincon/apps/Blackbook5/media/msp430
FlashSettings.h, NONE, 1.1 GenericCrcC.nc, NONE,
1.1 GenericCrc.nc, NONE, 1.1 GenericCrcM.nc, NONE,
1.1 FlashBridgeC.nc, NONE, 1.1 readme.txt, NONE,
1.1 FlashBridgeM.nc, NONE, 1.1
- Next message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/rincon/apps/Blackbook5/apps/StandaloneFull
TestBlackbookFullM.nc, 1.1, 1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-contrib-commits
mailing list