阅读官网文档:http://elm-chan.org/fsw/ff/doc/sync.html
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()
我们要在写之前添加好f_sync函数,将缓存的数据存储下去,有效防止写的数据全部被丢失
