閱讀官網文檔: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函數,將緩存的數據存儲下去,有效防止寫的數據全部被丟失