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