[Tinyos-2-commits] CVS: tinyos-2.x/tos/platforms/shimmer/chips/sd SD.nc, 1.1, 1.2 SDP.nc, 1.1, 1.2
Konrad Lorincz
konradlorincz at users.sourceforge.net
Thu Jul 10 14:35:32 PDT 2008
Update of /cvsroot/tinyos/tinyos-2.x/tos/platforms/shimmer/chips/sd
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv3157
Modified Files:
SD.nc SDP.nc
Log Message:
Updated SD interface
Index: SD.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/platforms/shimmer/chips/sd/SD.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** SD.nc 14 Jun 2008 22:49:29 -0000 1.1
--- SD.nc 10 Jul 2008 21:35:28 -0000 1.2
***************
*** 32,66 ****
*
* @author Steve Ayer
* @date May 2006
! */
!
#include "SD.h"
! interface SD {
!
! command mmcerror_t init ();
!
! command mmcerror_t setIdle();
!
! // we don't have pin for this one yet; it uses cd
! // command mmcerror_t detect();
!
! // change block length to 2^len bytes; default is 512
! command mmcerror_t setBlockLength (const uint16_t len);
!
! // see macro in module for writing to a sector instead of an address
! // read a block of size count from address
! command mmcerror_t readBlock(const uint32_t address, const uint16_t count, uint8_t * buffer);
! command mmcerror_t readSector(uint32_t sector, uint8_t * pBuffer);
!
! // see macro in module for writing to a sector instead of an address
! command mmcerror_t writeBlock (const uint32_t address, const uint16_t count, uint8_t * buffer);
! command mmcerror_t writeSector(uint32_t sector, uint8_t * pBuffer);
! // register read of length len into buffer
! command mmcerror_t readRegister(const uint8_t register, const uint8_t len, uint8_t * buffer);
! // Read the Card Size from the CSD Register
! // unsupported on sdio only cards
! command uint32_t readCardSize();
}
--- 32,66 ----
*
* @author Steve Ayer
+ * @author Konrad Lorincz
* @date May 2006
! */
#include "SD.h"
! interface SD
! {
! /**
! * Returns the card size in bytes.
! *
! * @return the card size in bytes.
! */
! command uint32_t readCardSize();
! /**
! * Reads 512 bytes from the SD at sector and copies it to bufferPtr
! *
! * @param sector the sector on the SD card (in multiples of 512 bytes).
! * @param bufferPtr pointer to where the SD will copy the data to. Must be 512 bytes.
! * @return <code>SUCCESS<code> if it was read successfully; <code>FAIL<code> otherwise
! */
! command error_t readBlock(const uint32_t sector, void *bufferPtr);
! /**
! * Writes 512 bytes from the bufferPtr to the SD card
! *
! * @param sector the sector on the SD card (in multiples of 512 bytes
! * where to write the data to).
! * @param bufferPtr pointer to data to be added. Must be 512 bytes.
! * @return <code>SUCCESS<code> if it was written successfully; <code>FAIL<code> otherwise
! */
! command error_t writeBlock(const uint32_t sector, void *bufferPtr);
}
Index: SDP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/platforms/shimmer/chips/sd/SDP.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** SDP.nc 14 Jun 2008 22:49:29 -0000 1.1
--- SDP.nc 10 Jul 2008 21:35:28 -0000 1.2
***************
*** 4,8 ****
* INCLUDING ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, ACCURACY OR
! * COMPLETENESS OF RESPONSES, RESULTS AND LACK OF NEGLIGENCE.
* TI DISCLAIMS ANY WARRANTY OF TITLE, QUIET ENJOYMENT, QUIET
* POSSESSION, AND NON-INFRINGEMENT OF ANY THIRD PARTY
--- 4,8 ----
* INCLUDING ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, ACCURACY OR
! * COMPLETENESS OF RESPONSES, RESULTS AND LACK OF NEGLIGENCE.
* TI DISCLAIMS ANY WARRANTY OF TITLE, QUIET ENJOYMENT, QUIET
* POSSESSION, AND NON-INFRINGEMENT OF ANY THIRD PARTY
***************
*** 114,121 ****
async event void HplMsp430UsartInterrupts.rxDone(uint8_t data) {/*do nothing*/}
- event void Boot.booted()
- {
- call SD.init();
- }
// This is from TOS 1.x!
--- 114,117 ----
***************
*** 271,288 ****
}
! command mmcerror_t SD.init(){
! register uint8_t i;
!
! initSPI();
!
! CS_HIGH();
!
! for(i = 0; i < 10; i++)
! spiSendByte(0xff);
!
! return call SD.setIdle();
! }
!
! command mmcerror_t SD.setIdle(){
char response;
CS_LOW();
--- 267,271 ----
}
! mmcerror_t SD_setIdle() {
char response;
CS_LOW();
***************
*** 308,316 ****
}
! // we don't have pin for this one yet; it uses cd pin, which we don't have wired in mock-up
! // command mmcerror_t detect();
// change block length to 2^len bytes; default is 512
! command mmcerror_t SD.setBlockLength (const uint16_t len) {
CS_LOW ();
--- 291,316 ----
}
! mmcerror_t SD_init() {
! register uint8_t i;
!
! initSPI();
!
! CS_HIGH();
!
! for(i = 0; i < 10; i++)
! spiSendByte(0xff);
!
! return SD_setIdle();
! }
+ event void Boot.booted()
+ {
+ SD_init();
+ }
+
+
+ // we don't have pin for this one yet; it uses cd pin, which we don't have wired in mock-up
// change block length to 2^len bytes; default is 512
! mmcerror_t SD_setBlockLength (const uint16_t len) {
CS_LOW ();
***************
*** 319,323 ****
// get response from card, should be 0; so, shouldn't this be 'while'?
if(getResponse() != 0x00){
! call SD.init();
sendCmd(MMC_SET_BLOCKLEN, len, 0xff);
getResponse();
--- 319,323 ----
// get response from card, should be 0; so, shouldn't this be 'while'?
if(getResponse() != 0x00){
! SD_init();
sendCmd(MMC_SET_BLOCKLEN, len, 0xff);
getResponse();
***************
*** 333,347 ****
- command mmcerror_t SD.readSector(uint32_t sector, uint8_t * pBuffer) {
- return call SD.readBlock(sector * 512, 512, pBuffer);
- }
-
// see macro in module for writing to a sector instead of an address
! command mmcerror_t SD.readBlock(const uint32_t address, const uint16_t count, uint8_t * buffer){
register uint16_t i = 0;
uint8_t rvalue = MMC_RESPONSE_ERROR;
// Set the block length to read
! if(call SD.setBlockLength(count) == MMC_SUCCESS){ // block length can be set
CS_LOW ();
--- 333,343 ----
// see macro in module for writing to a sector instead of an address
! mmcerror_t SD_readBlock(const uint32_t address, const uint16_t count, uint8_t * buffer){
register uint16_t i = 0;
uint8_t rvalue = MMC_RESPONSE_ERROR;
// Set the block length to read
! if(SD_setBlockLength(count) == MMC_SUCCESS){ // block length can be set
CS_LOW ();
***************
*** 383,397 ****
}
! command mmcerror_t SD.writeSector(uint32_t sector, uint8_t * pBuffer){
! return call SD.writeBlock(sector * 512, 512, pBuffer);
! }
!
!
! command mmcerror_t SD.writeBlock(const uint32_t address, const uint16_t count, uint8_t * buffer){
register uint16_t i;
uint8_t rvalue = MMC_RESPONSE_ERROR; // MMC_SUCCESS;
// Set the block length to write
! if(call SD.setBlockLength (count) == MMC_SUCCESS){ // block length could be set
// call Leds.yellowOn();
CS_LOW ();
--- 379,388 ----
}
! mmcerror_t SD_writeBlock(const uint32_t address, const uint16_t count, uint8_t * buffer){
register uint16_t i;
uint8_t rvalue = MMC_RESPONSE_ERROR; // MMC_SUCCESS;
// Set the block length to write
! if(SD_setBlockLength (count) == MMC_SUCCESS){ // block length could be set
// call Leds.yellowOn();
CS_LOW ();
***************
*** 434,442 ****
}
// register read of length len into buffer
! command mmcerror_t SD.readRegister(const uint8_t reg, const uint8_t len, uint8_t * buffer){
uint8_t uc, rvalue = MMC_TIMEOUT_ERROR;
! if((call SD.setBlockLength (len)) == MMC_SUCCESS){
CS_LOW ();
// CRC not used: 0xff as last byte
--- 425,453 ----
}
+ command error_t SD.readBlock(const uint32_t sector, void *bufferPtr)
+ {
+ mmcerror_t mmcerror = SD_readBlock(sector * 512, 512, bufferPtr);
+ if (mmcerror == MMC_SUCCESS)
+ return SUCCESS;
+ else
+ return FAIL;
+ }
+
+
+ command error_t SD.writeBlock(const uint32_t sector, void *bufferPtr)
+ {
+ mmcerror_t mmcerror = SD_writeBlock(sector * 512, 512, bufferPtr);
+ if (mmcerror == MMC_SUCCESS)
+ return SUCCESS;
+ else
+ return FAIL;
+ }
+
+
// register read of length len into buffer
! mmcerror_t SD_readRegister(const uint8_t reg, const uint8_t len, uint8_t * buffer){
uint8_t uc, rvalue = MMC_TIMEOUT_ERROR;
! if((SD_setBlockLength (len)) == MMC_SUCCESS){
CS_LOW ();
// CRC not used: 0xff as last byte
More information about the Tinyos-2-commits
mailing list