Changeset 529 for soft/giet_vm/giet_drivers/sdc_driver.c
- Timestamp:
- Mar 27, 2015, 11:51:33 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_drivers/sdc_driver.c
r456 r529 372 372 if (sdcard_rsp) 373 373 { 374 _puts("[SDC ERROR] During SD card block leninitialization\n");374 _puts("[SDC ERROR] During SD card block size initialization\n"); 375 375 _exit(); 376 376 } … … 389 389 390 390 return 0; 391 } 392 393 394 ////////////////////////////////////////// 395 unsigned int _sdc_read( unsigned int mode, 396 unsigned int lba, 397 paddr_t buffer, 398 unsigned int count ) 391 } // end _sdc_init() 392 393 394 ///////////////////////////////////////////////////// 395 unsigned int _sdc_access( unsigned int use_irq, // unused 396 unsigned int to_mem, 397 unsigned int lba, 398 unsigned long long buf_paddr, 399 unsigned int count ) 399 400 { 400 401 unsigned char args[4]; … … 404 405 unsigned int last = lba + count; 405 406 406 for ( ; curr < last ; curr++ ) 407 { 408 _sdc_lseek(curr); 409 410 for (i = 0; i < 4; i++) 411 { 412 args[i] = (sdcard.access_pointer >> (32 - (i+1)*8)) & 0xFF; 407 if ( to_mem ) // read access 408 { 409 for ( ; curr < last ; curr++ ) 410 { 411 _sdc_lseek(curr); 412 413 for (i = 0; i < 4; i++) 414 { 415 args[i] = (sdcard.access_pointer >> (32 - (i+1)*8)) & 0xFF; 416 } 417 418 _sdc_enable(); 419 420 sdcard_rsp = _sdc_send_command(17, SDCARD_CMD, args, 0x00); 421 if ( SDCARD_CHECK_R1_ERROR(sdcard_rsp) ) 422 { 423 _sdc_disable(); 424 return sdcard_rsp; 425 } 426 427 _sdc_wait_data_block(); 428 429 if (spi_get_data(sdcard.spi, buf_paddr, 512 )) 430 { 431 _sdc_disable(); 432 return 1; 433 } 434 435 // Get the CRC16 (comes at the end of the data block) 436 _sdc_receive_char(); // first byte 437 _sdc_receive_char(); // second byte 438 439 _sdc_disable(); 440 441 buf_paddr += 512; 413 442 } 414 415 _sdc_enable(); 416 417 sdcard_rsp = _sdc_send_command(17, SDCARD_CMD, args, 0x00); 418 if ( SDCARD_CHECK_R1_ERROR(sdcard_rsp) ) 419 { 420 _sdc_disable(); 421 return sdcard_rsp; 422 } 423 424 _sdc_wait_data_block(); 425 426 if (spi_get_data(sdcard.spi, buffer, 512 )) 427 { 428 _sdc_disable(); 429 return 1; 430 } 431 432 // Get the CRC16 (comes at the end of the data block) 433 _sdc_receive_char(); // first byte 434 _sdc_receive_char(); // second byte 435 436 _sdc_disable(); 437 438 buffer += 512; 443 } 444 else // write access 445 { 446 _printf("[SDC ERROR] function _sdc_write() not iplemented yet\n"); 447 _exit(); 439 448 } 440 449 441 450 return 0; 442 } 443 444 /////////////////////////////////////////// 445 unsigned int _sdc_write( unsigned int mode, 446 unsigned int lba, 447 paddr_t buffer, 448 unsigned int count ) 449 { 450 _puts("[SDC ERROR] function _sdc_write() not iplemented yet\n"); 451 _exit(); 452 453 return 0; // to avoid a warning 454 } 455 456 ////////////////////////////// 457 unsigned int _sdc_get_status() 458 { 459 _puts("[SDC ERROR] function _sdc_get_status() should not be called\n"); 460 _exit(); 461 462 return 0; // to avoid a warning 463 } 464 465 ////////////////////////////////// 466 unsigned int _sdc_get_block_size() 467 { 468 if (sdcard.sdhc) return sdcard.block_length*512; 469 else return sdcard.block_length; 470 } 451 } // _end sdc_access() 471 452 472 453 // Local Variables:
Note: See TracChangeset
for help on using the changeset viewer.