Changeset 437 for soft/giet_vm/giet_drivers/sdc_driver.c
- Timestamp:
- Nov 3, 2014, 10:53:00 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_drivers/sdc_driver.c
r320 r437 18 18 19 19 /////////////////////////////////////////////////////////////////////////////// 20 // _sdc_enable()21 20 // This function enables SD Card select signal 22 21 /////////////////////////////////////////////////////////////////////////////// … … 27 26 28 27 /////////////////////////////////////////////////////////////////////////////// 29 // _sdc_enable()30 28 // This function disables SD Card select signal 31 29 /////////////////////////////////////////////////////////////////////////////// … … 36 34 37 35 /////////////////////////////////////////////////////////////////////////////// 38 // _sdc_gen_tick()39 36 // This function writes on the SPI tx register to generate SD card clock ticks 40 37 // - tick_count: number of ticks to generate (1 tick -> 8 clocks) … … 47 44 48 45 /////////////////////////////////////////////////////////////////////////////// 49 // _sdc_lseek()50 46 // This function changes the SD card access pointer position in terms of 51 47 // blocks … … 58 54 59 55 /////////////////////////////////////////////////////////////////////////////// 60 // _sdc_receive_char()61 56 // This function gets a byte from the SD card 62 57 /////////////////////////////////////////////////////////////////////////////// … … 69 64 70 65 /////////////////////////////////////////////////////////////////////////////// 71 // _sdc_wait_response()72 66 // This function returns when a valid response from the SD card is received or 73 67 // a timeout has been triggered … … 94 88 95 89 /////////////////////////////////////////////////////////////////////////////// 96 // _sdc_wait_data_block()97 90 // This function returns when a data block from the SD card is received (data 98 91 // block start marker received). … … 105 98 106 99 /////////////////////////////////////////////////////////////////////////////// 107 // _sdc_send_command()108 100 // This function sends a command to the SD card 109 101 // - index: CMD index … … 153 145 154 146 /////////////////////////////////////////////////////////////////////////////// 155 // _sdc_open()156 147 // This function initializes the SD card (reset procedure) 157 148 // - channel: channel index (only channel 0 is supported) … … 182 173 if ( sdcard_rsp != 0x01 ) 183 174 { 184 _p rintf("[SDC ERROR] card CMD0 failed\n");175 _puts("[SDC ERROR] card CMD0 failed\n"); 185 176 return sdcard_rsp; 186 177 } … … 198 189 if (!SDCARD_CHECK_R1_VALID(sdcard_rsp)) 199 190 { 200 _p rintf("[SDC ERROR] card CMD8 failed\n");191 _puts("[SDC ERROR] card CMD8 failed\n"); 201 192 return sdcard_rsp; 202 193 } … … 211 202 { 212 203 // voltage mismatch 213 _p rintf("[SDC ERROR] card CMD8 mismatch : ersp = %x\n");204 _puts("[SDC ERROR] card CMD8 mismatch : ersp = %x\n"); 214 205 return sdcard_rsp; 215 206 } 216 _p rintf("[SDC WARNING] v2 or later ");207 _puts("[SDC WARNING] v2 or later "); 217 208 sdcard.sdhc = 1; 218 209 } … … 220 211 { 221 212 // other error 222 _p rintf("[SDC ERROR] card CMD8 error\n");213 _puts("[SDC ERROR] card CMD8 error\n"); 223 214 return sdcard_rsp; 224 215 } … … 251 242 if (sdcard_rsp) 252 243 { 253 _p rintf("[SDC ERROR] ACMD41 failed\n");244 _puts("[SDC ERROR] ACMD41 failed\n"); 254 245 return sdcard_rsp; 255 246 } … … 265 256 if (sdcard_rsp) 266 257 { 267 _p rintf("[SDC ERROR] CMD58 failed\n");258 _puts("[SDC ERROR] CMD58 failed\n"); 268 259 return sdcard_rsp; 269 260 } … … 274 265 if (ersp & 0x40000000) 275 266 { 276 _p rintf(" SDHC ");267 _puts(" SDHC "); 277 268 } 278 269 else … … 282 273 _sdc_disable(); 283 274 } 284 _p rintf("card detected\n");275 _puts("card detected\n"); 285 276 return 0; 286 277 } 287 278 288 279 /////////////////////////////////////////////////////////////////////////////// 289 // _sdc_set_block_size() 290 // This function sets the block size in bytes of the SD card 280 // This function sets the block size in the SD card. 291 281 // - len: block size in bytes (only 512 bytes supported) 292 282 // Returns 0 if success, other value if failure … … 330 320 } 331 321 332 /////////////////////////////////////////////////////////////////////////////// 333 // _sdc_init() 334 // This function initializes the SPI controller and call sdc_open to 335 // initializes SD card 336 // - channel: channel to initialize (only channel 0 supported) 337 // Returns 0 if success, other value if failure 338 /////////////////////////////////////////////////////////////////////////////// 322 ///////////////////////////////////////////////////////////////////////////////// 323 // Extern functions 324 ///////////////////////////////////////////////////////////////////////////////// 325 326 //////////////////////// 339 327 unsigned int _sdc_init() 340 328 { … … 358 346 while(1) 359 347 { 360 _p rintf("[SDC WARNING] Trying to initialize SD card...\n");348 _puts("[SDC WARNING] Trying to initialize SD card...\n"); 361 349 362 350 sdcard_rsp = _sdc_open( 0 ); // only channel 0 363 351 if (sdcard_rsp == 0) 364 352 { 365 _p rintf("OK\n");353 _puts("OK\n"); 366 354 break; 367 355 } 368 356 369 _p rintf("KO\n");357 _puts("KO\n"); 370 358 371 359 for (i = 0; i < 1000; i++); … … 373 361 if (++iter >= SDCARD_RESET_ITER_MAX) 374 362 { 375 _printf("\n[SDC ERROR] During SD card reset to IDLE state " 376 "/ card response = %x\n", sdcard_rsp ); 363 _puts("\n[SDC ERROR] During SD card reset / card response = "); 364 _putx( sdcard_rsp ); 365 _puts("\n"); 377 366 _exit(); 378 367 } … … 383 372 if (sdcard_rsp) 384 373 { 385 _p rintf("[SDC ERROR] During SD card blocklen initialization\n");374 _puts("[SDC ERROR] During SD card blocklen initialization\n"); 386 375 _exit(); 387 376 } … … 397 386 ); 398 387 399 _p rintf("[SDC WARNING] Finish SD card initialization\n\r");388 _puts("[SDC WARNING] Finish SD card initialization\n\r"); 400 389 401 390 return 0; … … 403 392 404 393 405 /////////////////////////////////////////////////////////////////////////////// 406 // _sdc_read() 407 // Transfer data from the block device to a memory buffer. 408 // - mode : BOOT / KERNEL / USER 409 // - lba : first block index on the block device 410 // - buffer : base address of the memory buffer (must be word aligned) 411 // - count : number of blocks to be transfered. 412 // Returns 0 if success, > 0 if error. 413 /////////////////////////////////////////////////////////////////////////////// 394 ////////////////////////////////////////// 414 395 unsigned int _sdc_read( unsigned int mode, 415 396 unsigned int lba, … … 461 442 } 462 443 463 /////////////////////////////////////////////////////////////////////////////// 464 // _sdc_write() (not supported for now) 465 // Transfer data from memory buffer to SD card device. 466 // - mode : BOOT / KERNEL / USER 467 // - lba : destination first block index on the SD card 468 // - buffer : base address of the memory buffer (must be word aligned) 469 // - count : number of blocks to be transfered. 470 // Returns 0 if success, > 0 if error. 471 /////////////////////////////////////////////////////////////////////////////// 444 /////////////////////////////////////////// 472 445 unsigned int _sdc_write( unsigned int mode, 473 446 unsigned int lba, … … 475 448 unsigned int count ) 476 449 { 477 return 0; 478 } 479 480 /////////////////////////////////////////////////////////////////////////////// 481 // Transfer data from memory buffer to SD card device. 482 // - channel: channel index 483 // - status: this pointer is used to transmit the status value to caller. 484 // Returns 0 if success, > 0 if error. 485 /////////////////////////////////////////////////////////////////////////////// 450 _puts("[SDC ERROR] function _sdc_write() not iplemented yet\n"); 451 _exit(); 452 453 return 0; // to avoid a warning 454 } 455 456 ////////////////////////////// 486 457 unsigned int _sdc_get_status() 487 458 { 488 _p rintf("[SDC ERROR] function _sdc_get_status() should not be called\n");459 _puts("[SDC ERROR] function _sdc_get_status() should not be called\n"); 489 460 _exit(); 490 461 … … 492 463 } 493 464 494 /////////////////////////////////////////////////////////////////////////////// 495 // Returns the block size in bytes of the SD card 496 /////////////////////////////////////////////////////////////////////////////// 465 ////////////////////////////////// 497 466 unsigned int _sdc_get_block_size() 498 467 {
Note: See TracChangeset
for help on using the changeset viewer.