コード例 #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)))