예제 #1
0
 def read(self, sector):
     """read a sector (512 bytes) from the card. argument is the sector number (512 bytes)
        returns a string with the binary data"""
     self.command(MMC_READ_SINGLE_BLOCK, sector * 512)
     if self.dataToken() != 0xFE:  # check answer
         raise MMCError_no_answer  # Fehler
     data = hilspi.shift("\xff" * 512)
     hilspi.shift("\xff" * 2)  # Dummy-CRC
     return data
예제 #2
0
파일: mmc.py 프로젝트: jfdawson20/ti-leaf
 def read(self, sector):
     """read a sector (512 bytes) from the card. argument is the sector number (512 bytes)
        returns a string with the binary data"""
     self.command(MMC_READ_SINGLE_BLOCK, sector * 512)
     if self.dataToken() != 0xFE:  # check answer
         raise MMCError_no_answer  # Fehler
     data = hilspi.shift("\xff" * 512)
     hilspi.shift("\xff" * 2)  # Dummy-CRC
     return data
예제 #3
0
 def info(self):
     """get a dictionary with some card info in it"""
     info = {}
     self.command(MMC_SEND_CID, 0x00000000)
     if (self.dataToken() != 0xFE):
         raise MMCError("error during CID read")
     hilspi.shift("\xff" * 3)
     info["Product Name:"] = hilspi.shift("\xff" * 6)
     hilspi.shift("\xff" * 7)
     return info
예제 #4
0
파일: mmc.py 프로젝트: jfdawson20/ti-leaf
 def info(self):
     """get a dictionary with some card info in it"""
     info = {}
     self.command(MMC_SEND_CID, 0x00000000)
     if self.dataToken() != 0xFE:
         raise MMCError("error during CID read")
     hilspi.shift("\xff" * 3)
     info["Product Name:"] = hilspi.shift("\xff" * 6)
     hilspi.shift("\xff" * 7)
     return info
예제 #5
0
 def write(self, sector, data):
     """write the given data in the specified sector"""
     if len(data) != 512:
         raise ValueError("Can only handle blocks of 512 bytes size")
     self.command(MMC_WRITE_BLOCK, sector * 512)
     if self.get() == 0xFF:
         raise MMCError_no_answer
     SpiByte(0xFE)  # Start-Byte
     data = hilspi.shift(data)
     hilspi.shift("\xff" * 2)  # Dummy-CRC
     SpiByte(0xFF)
     # lese Antwort-Byte
     for i in range(50000):
         if SpiByte(0xFF) != 0x00:
             break
     else:
         raise MMCError("error while writing data")
예제 #6
0
파일: mmc.py 프로젝트: jfdawson20/ti-leaf
 def write(self, sector, data):
     """write the given data in the specified sector"""
     if len(data) != 512:
         raise ValueError("Can only handle blocks of 512 bytes size")
     self.command(MMC_WRITE_BLOCK, sector * 512)
     if self.get() == 0xFF:
         raise MMCError_no_answer
     SpiByte(0xFE)  # Start-Byte
     data = hilspi.shift(data)
     hilspi.shift("\xff" * 2)  # Dummy-CRC
     SpiByte(0xFF)
     # lese Antwort-Byte
     for i in range(50000):
         if SpiByte(0xFF) != 0x00:
             break
     else:
         raise MMCError("error while writing data")
예제 #7
0
def SpiByte(byte):
    return ord(hilspi.shift(chr(byte)))
예제 #8
0
파일: mmc.py 프로젝트: jfdawson20/ti-leaf
def SpiByte(byte):
    return ord(hilspi.shift(chr(byte)))