release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide

# Rockbox mail archive

Subject: Re: Lyre project -- what I am being doing

# Re: Lyre project -- what I am being doing

From: Casainho <casainho_at_gmail.com>
Date: Tue, 17 Mar 2009 09:54:34 +0000

> But now most part of time I get an SD Card error, so, I am working now
> to make the SD Card drivers more robust, mainly I will start using the
> CRC7 for commands...
>
> I am using CRC16 for data readed from SD Card. I got errors while
> reading sectors(512 bytes) but after testing with CRC16, I detect them
> and I just read again.

Ex1:
List[0]=0x40
List[1]=0x00
List[2]=0x00
List[3]=0x00
List[4]=0x00
Length = 5
CRC = 0x95

Ex2:
List[0]=0x40
List[1]=0x00
List[2]=0x00
List[3]=0x00
List[4]=0x31
Length = 5
CRC = 0xD1

// _____________________________________________________________________________________________
//
// Function: SD_CRC_7()
//
// Description:
// ------------
// calulates the 7-bit CRC for a list of bytes...
//
// Design Notes:
// -------------
// In the case of CRC-7, the remainder can be calculated using a 7-bit
shift register in
// software. This shift register is initialized to all zeros at the
start of the calculation. As
// each bit (MSB first) of the protected data is shifted into the LSB
of the shift register,
// the MSB of the shift register is shifted out and examined. If the
bit just shifted out is
// one, the contents of the shift register are modified by XORing with
the CRC-7 polynomial
// value 0x09. If the bit shifted out of the shift register is zero,
no XOR is performed. Once
// the last bit of protected data is shifted in and the conditional
XOR completed, six more
// zeros must be shifted through in a similar manner. This process is
referred to as
// augmentation, and completes the polynomial division. At this point,
the CRC-7 value can be
// read directly from the shift register.
// _____________________________________________________________________________________________
//
BYTE SD_CRC_7( BYTE *List, BYTE Length )
{
idata BYTE crc = 0x00;

for( i=0; i<Length; i++ )
{
for( j=0; j<8; j++)
{
crc <<= 1;
if(( mask & 0x80 ) ^ ( crc & 0x80 ) )
crc ^= 0x09;