]> cloudbase.mooo.com Git - z180-stamp.git/blame - fatfs/documents/doc/dwrite.html
Import fatfs R0.13b
[z180-stamp.git] / fatfs / documents / doc / dwrite.html
CommitLineData
53668523
L
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">\r
2<html lang="en">\r
3<head>\r
289f6a14 4<meta http-equiv="Content-Type" content="text/html; charset=utf-8">\r
53668523
L
5<meta http-equiv="Content-Style-Type" content="text/css">\r
6<link rel="up" title="FatFs" href="../00index_e.html">\r
7<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/dwrite.html">\r
8<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">\r
9<title>FatFs - disk_write</title>\r
10</head>\r
11\r
12<body>\r
13\r
14<div class="para func">\r
15<h2>disk_write</h2>\r
289f6a14 16<p>The disk_write function is called to write data to the sector(s) of storage device.</p>\r
53668523
L
17<pre>\r
18DRESULT disk_write (\r
289f6a14 19 BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] Physical drive number */</span>\r
53668523
L
20 const BYTE* <span class="arg">buff</span>, <span class="c">/* [IN] Pointer to the data to be written */</span>\r
21 DWORD <span class="arg">sector</span>, <span class="c">/* [IN] Sector number to write from */</span>\r
22 UINT <span class="arg">count</span> <span class="c">/* [IN] Number of sectors to write */</span>\r
23);\r
24</pre>\r
25</div>\r
26\r
27<div class="para arg">\r
28<h4>Parameters</h4>\r
29<dl class="par">\r
30<dt>pdrv</dt>\r
31<dd>Physical drive number to identify the target device.</dd>\r
32<dt>buff</dt>\r
70702af1 33<dd>Pointer to the first item of 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>\r
53668523 34<dt>sector</dt>\r
7b78a5a2 35<dd>Start sector number in 32-bit LBA.</dd>\r
53668523 36<dt>count</dt>\r
70702af1 37<dd>Number of sectors to write.</dd>\r
53668523
L
38</dl>\r
39</div>\r
40\r
41\r
42<div class="para ret">\r
43<h4>Return Values</h4>\r
44<dl class="ret">\r
45<dt>RES_OK (0)</dt>\r
46<dd>The function succeeded.</dd>\r
47<dt>RES_ERROR</dt>\r
289f6a14 48<dd>An unrecoverable hard error occured during the write operation.</dd>\r
53668523
L
49<dt>RES_WRPRT</dt>\r
50<dd>The medium is write protected.</dd>\r
51<dt>RES_PARERR</dt>\r
52<dd>Invalid parameter.</dd>\r
53<dt>RES_NOTRDY</dt>\r
54<dd>The device has not been initialized.</dd>\r
55</dl>\r
56</div>\r
57\r
58\r
59<div class="para desc">\r
60<h4>Description</h4>\r
289f6a14
L
61<p>The specified memory address is not that always aligned to word boundary because the argument 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>\r
62<p>Generally, a multiple sector write request (<tt class="arg">count</tt><tt> &gt; 1</tt>) must not be split into single sector transactions to the storage device, or the file write throughput will be drastically decreased.</p>\r
63<p>FatFs expects delayed write function of the disk control layer. The write operation to the media does not need to be completed at return from this function by what write operation is in progress or data is only stored into the write-back cache. But write 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 a delayed write function is implemented, the write throughput of the filesystem will be improved.</p>\r
70702af1 64<p><em>Remarks: Application program MUST NOT call this function, or FAT structure on the volume can be collapsed.</em></p>\r
53668523
L
65</div>\r
66\r
67\r
68<div class="para comp">\r
69<h4>QuickInfo</h4>\r
289f6a14 70<p>This function is not needed when <tt><a href="config.html#fs_readonly">FF_FS_READONLY</a> == 1</tt>.</p>\r
53668523
L
71</div>\r
72\r
73\r
74<p class="foot"><a href="../00index_e.html">Return</a></p>\r
75</body>\r
76</html>\r