From 5630b9308323c3f3aaa09be8fe0f3aecaa826473 Mon Sep 17 00:00:00 2001 From: Leo C. Date: Sun, 30 Jun 2024 09:37:28 +0200 Subject: Import fatfs R0.15 --- fatfs/documents/doc/sync.html | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'fatfs/documents/doc/sync.html') 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 (

Description

-

The f_sync function performs the same process as f_close 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 f_sync function of periodic or immediataly after f_write function can minimize the risk of data loss due to a sudden blackout or an unintentional media removal. For more information, refer to application note.

+

The f_sync function performs the same process as f_close 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 f_sync 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 application note.

+
+Case 1. Normal write sequence
+
+                                Time -->                                     ↓Normal shutdown
+OwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwC <Power off>
+
+
+Case 2. Without using f_sync()
+
+                                Time -->                             ↓System crush
+Owwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
+ |<--------------- All data written will be lost ------------------>|
+
+
+Case 3. Using f_sync()
+                                Time -->                             ↓System crush
+OwwwwwwwwSwwwwwwwwSwwwwwwwwSwwwwwwwwSwwwwwwwwSwwwwwwwwSwwwwwwwwSwwwww
+                            Data after last f_sync will be lost |<->| 
+O - f_open()
+C - f_close()
+w - f_write()
+S - f_sync()
+

However there is no sense in f_sync function immediataly before f_close function because it performs f_sync function in it. In other words, the differnce between those functions is that the file object is invalidated or not.

-- cgit v1.2.3