Subversion Repositories NaviCtrl

Rev

Rev 119 | Rev 149 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 119 Rev 146
Line 270... Line 270...
270
 
270
 
271
SD_Result_t SDC_GetData(u8 CmdNo, u32 addr, u8 *Buffer, u32 len)
271
SD_Result_t SDC_GetData(u8 CmdNo, u32 addr, u8 *Buffer, u32 len)
272
{
272
{
273
        u8 rsp;        
273
        u8 rsp;        
-
 
274
        u16 a, crc16;
274
        u16 a, crc16;
275
        u32 timeout;
Line 275... Line 276...
275
        SD_Result_t result = SD_ERROR_UNKNOWN;
276
        SD_Result_t result = SD_ERROR_UNKNOWN;
276
 
277
 
277
        // send the command     
278
        // send the command     
278
        rsp = SDC_SendCMDR1(CmdNo, addr);
279
        rsp = SDC_SendCMDR1(CmdNo, addr);
279
        if (rsp != R1_NO_ERR)
280
        if (rsp != R1_NO_ERR)
280
        {
281
        {
281
                result = SD_ERROR_BAD_RESPONSE;
282
                result = SD_ERROR_BAD_RESPONSE;
282
                goto end;
283
                goto end;
-
 
284
        }
283
        }
285
        SSC_ClearRxFifo();
284
        SSC_ClearRxFifo();
286
        timeout = SetDelay(500);
285
        do
287
        do
286
        {
288
        {
287
                rsp = SSC_GetChar();
289
                rsp = SSC_GetChar();
288
                if((rsp & 0xF0) == 0x00) // data error token 
290
                if( ( (rsp & 0xF0) == 0x00 ) || CheckDelay(timeout) ) // data error token or timeout 
289
                {
291
                {
290
                        result = SD_ERROR_READ_DATA;
292
                        result = SD_ERROR_READ_DATA;
291
                        goto end;
293
                        goto end;
Line 295... Line 297...
295
        for (a = 0; a < len; a++)       // read the block from the SSC
297
        for (a = 0; a < len; a++)       // read the block from the SSC
296
        {
298
        {
297
                Buffer[a] = SSC_GetChar();
299
                Buffer[a] = SSC_GetChar();
298
        }
300
        }
299
        // Read two bytes CRC16-Data checksum
301
        // Read two bytes CRC16-Data checksum
300
        crc16 = SSC_GetChar(); // highbyte fisrt        
302
        crc16 = SSC_GetChar(); // highbyte first        
301
        crc16 = (crc16<<8)|SSC_GetChar(); // lowbyte last
303
        crc16 = (crc16<<8)|SSC_GetChar(); // lowbyte last
302
/*      if(crc16 != CRC16(Buffer, len)) result = SD_ERROR_CRC_DATA;
304
/*      if(crc16 != CRC16(Buffer, len)) result = SD_ERROR_CRC_DATA;
303
        else */result = SD_SUCCESS;
305
        else */result = SD_SUCCESS;
Line 304... Line 306...
304
       
306