summaryrefslogtreecommitdiff
path: root/fatfs/documents/doc/sync.html
diff options
context:
space:
mode:
Diffstat (limited to 'fatfs/documents/doc/sync.html')
-rw-r--r--fatfs/documents/doc/sync.html25
1 files changed, 24 insertions, 1 deletions
diff --git a/fatfs/documents/doc/sync.html b/fatfs/documents/doc/sync.html
index a0317d6..9fb42a0 100644
--- a/fatfs/documents/doc/sync.html
+++ b/fatfs/documents/doc/sync.html
@@ -44,7 +44,30 @@ FRESULT f_sync (
<div class="para desc">
<h4>Description</h4>
-<p>The <tt>f_sync</tt> function performs the same process as <tt>f_close</tt> function but the file is left opened and can continue read/write/seek operations to the file. This is suitable for the applications that open files for a long time in write mode, such as data logger. Performing <tt>f_sync</tt> function of periodic or immediataly after <tt>f_write</tt> function can minimize the risk of data loss due to a sudden blackout or an unintentional media removal. For more information, refer to <a href="appnote.html#critical">application note</a>.</p>
+<p>The <tt>f_sync</tt> function performs the same process as <tt>f_close</tt> function but the file is left opened and can continue read/write/seek operations to the file. This is suitable for the applications that open files for a long time in write mode, such as data logger. Performing <tt>f_sync</tt> function in certain interval can minimize the risk of data loss due to a sudden blackout, wrong media removal or unrecoverable disk error. For more information, refer to <a href="appnote.html#critical">application note</a>.</p>
+<pre>
+Case 1. Normal write sequence
+
+ Time --&gt; ↓Normal shutdown
+OwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwC &lt;Power off&gt;
+
+
+Case 2. Without using f_sync()
+
+ Time --&gt; ↓System crush
+O<span class="e">wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww</span>
+ |&lt;--------------- All data written will be lost ------------------&gt;|
+
+
+Case 3. Using f_sync()
+ Time --&gt; ↓System crush
+OwwwwwwwwSwwwwwwwwSwwwwwwwwSwwwwwwwwSwwwwwwwwSwwwwwwwwSwwwwwwwwS<span class="e">wwwww</span>
+ Data after last f_sync will be lost |&lt;-&gt;|
+O - f_open()
+C - f_close()
+w - f_write()
+S - f_sync()
+</pre>
<p>However there is no sense in <tt>f_sync</tt> function immediataly before <tt>f_close</tt> function because it performs <tt>f_sync</tt> function in it. In other words, the differnce between those functions is that the file object is invalidated or not.</p>
</div>