dread.html 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html lang="en">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  5. <meta http-equiv="Content-Style-Type" content="text/css">
  6. <link rel="up" title="FatFs" href="../00index_e.html">
  7. <link rel="alternate" hreflang="ja" title="Japanese" href="../ja/dread.html">
  8. <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
  9. <title>FatFs - disk_read</title>
  10. </head>
  11. <body>
  12. <div class="para func">
  13. <h2>disk_read</h2>
  14. <p>The disk_read function reads sector(s) from the storage device.</p>
  15. <pre>
  16. DRESULT disk_read (
  17. BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] Physical drive number */</span>
  18. BYTE* <span class="arg">buff</span>, <span class="c">/* [OUT] Pointer to the read data buffer */</span>
  19. DWORD <span class="arg">sector</span>, <span class="c">/* [IN] Start sector number */</span>
  20. UINT <span class="arg">count</span> <span class="c">/* [IN] Number of sectros to read */</span>
  21. );
  22. </pre>
  23. </div>
  24. <div class="para arg">
  25. <h4>Parameters</h4>
  26. <dl class="par">
  27. <dt>pdrv</dt>
  28. <dd>Physical drive number to identify the target device.</dd>
  29. <dt>buff</dt>
  30. <dd>Pointer to the <em>byte array</em> to store the read data.</dd>
  31. <dt>sector</dt>
  32. <dd>Start sector number in logical block address (LBA).</dd>
  33. <dt>count</dt>
  34. <dd>Number of sectors to read. FatFs specifis it in range of from 1 to 128.</dd>
  35. </dl>
  36. </div>
  37. <div class="para ret">
  38. <h4>Return Value</h4>
  39. <dl class="ret">
  40. <dt>RES_OK (0)</dt>
  41. <dd>The function succeeded.</dd>
  42. <dt>RES_ERROR</dt>
  43. <dd>Any hard error occured during the read operation and could not recover it.</dd>
  44. <dt>RES_PARERR</dt>
  45. <dd>Invalid parameter.</dd>
  46. <dt>RES_NOTRDY</dt>
  47. <dd>The device has not been initialized.</dd>
  48. </dl>
  49. </div>
  50. <div class="para desc">
  51. <h4>Description</h4>
  52. <p>The memory address specified by <tt class="arg">buff</tt> is not that always aligned to word boundary because the type of argument is defined as <tt>BYTE*</tt>. The misaligned read/write request can occure at <a href="appnote.html#fs1">direct transfer</a>. If the bus architecture, especially DMA controller, does not allow misaligned memory access, it should be solved in this function. There are some workarounds described below to avoid this issue.</p>
  53. <ul>
  54. <li>Convert word transfer to byte transfer in this function. - Recommended.</li>
  55. <li>For <tt>f_read()</tt>, avoid long read request that includes a whole of sector. - Direct transfer will never occure.</li>
  56. <li>For <tt>f_read(fp, buff, btr, &amp;br)</tt>, make sure that <tt>(((UINT)buff &amp; 3) == (f_tell(fp) &amp; 3))</tt> is true. - Word aligned direct transfer is guaranteed.</li>
  57. </ul>
  58. <p>Generally, a multiple sector transfer request must not be split into single sector transactions to the storage device, or you will not get good read throughput.</p>
  59. </div>
  60. <p class="foot"><a href="../00index_e.html">Return</a></p>
  61. </body>
  62. </html>