dwrite.html 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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/dwrite.html">
  8. <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
  9. <title>FatFs - disk_write</title>
  10. </head>
  11. <body>
  12. <div class="para func">
  13. <h2>disk_write</h2>
  14. <p>The disk_write writes sector(s) to the storage device.</p>
  15. <pre>
  16. DRESULT disk_write (
  17. BYTE <span class="arg">drv</span>, <span class="c">/* [IN] Physical drive number */</span>
  18. const BYTE* <span class="arg">buff</span>, <span class="c">/* [IN] Pointer to the data to be written */</span>
  19. DWORD <span class="arg">sector</span>, <span class="c">/* [IN] Sector number to write from */</span>
  20. UINT <span class="arg">count</span> <span class="c">/* [IN] Number of sectors to write */</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 be written. The size of data to be written is sector size * <tt class="arg">count</tt> bytes.</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 write. FatFs specifis it in range of from 1 to 128.</dd>
  35. </dl>
  36. </div>
  37. <div class="para ret">
  38. <h4>Return Values</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 write operation and could not recover it.</dd>
  44. <dt>RES_WRPRT</dt>
  45. <dd>The medium is write protected.</dd>
  46. <dt>RES_PARERR</dt>
  47. <dd>Invalid parameter.</dd>
  48. <dt>RES_NOTRDY</dt>
  49. <dd>The device has not been initialized.</dd>
  50. </dl>
  51. </div>
  52. <div class="para desc">
  53. <h4>Description</h4>
  54. <p>The specified memory address is not that always aligned to word boundary because the type of pointer is defined as <tt>BYTE*</tt>. For more information, refer to the description of <a href="dread.html"><tt>disk_read()</tt></a> function.</p>
  55. <p>Generally, a multiple sector transfer request must not be split into single sector transactions to the storage device, or you will never get good write throughput.</p>
  56. <p>FatFs expects delayed write feature of the disk functions. The write operation to the media need not to be completed due to write operation is in progress or only stored it into the cache buffer when return from this function. But data on the <tt class="arg">buff</tt> is invalid after return from this function. The write completion request is done by <tt>CTRL_SYNC</tt> command of <tt><a href="dioctl.html">disk_ioctl()</a></tt> function. Therefore, if delayed write feature is implemented, the write throughput may be improved.</p>
  57. <p><em>Application program MUST NOT call this function, or FAT structure on the volume can be collapsed.</em></p>
  58. </div>
  59. <div class="para comp">
  60. <h4>QuickInfo</h4>
  61. <p>This function is not needed when <tt>_FS_READONLY == 1</tt>.</p>
  62. </div>
  63. <p class="foot"><a href="../00index_e.html">Return</a></p>
  64. </body>
  65. </html>