SdRaw_Flush()

… visits
Parent Previous Next

Syntax

SdRaw_Flush(), Bit

Return value

Value

Meaning

1 / True

There was nothing to write, or the pending write completed successfully.

0 / False

The pending write did not succeed.


Writes pending byte changes from the cached sector to the SD card, then waits for the card to finish programming. If the cache has no unwritten changes, there is nothing to write.


When to call it

Call SdRaw_Flush() before switching off power, removing the card, or filling SectorBuffer[] by hand. Check the return value before treating pending data as saved.


In RAW mode, the library automatically flushes the buffer when switching between byte-oriented and sector-oriented operations. An explicit flush is still useful after a group of writes or before an idle period, so the latest changes do not remain only in RAM.

Example

' Run after your RAW byte writes.

If SdRaw_Flush() = 1 Then

    ' Pending cached changes have been written, or none were pending.

Else

    ' Handle the write failure before removing power or the card.

EndIf

Notes

RAW-mode counterpart to closing a file: This serves the data-commit role associated with FileClose() in FAT16/FAT32 mode. RAW mode has no FAT file to close; the operation writes the pending cached sector.

Flush before changing SectorBuffer[] manually, while it still contains the cached data you need to save. The call does not replace the sector-write operation used to store a newly prepared buffer.

See also

SdRaw_WriteByte() · SdRaw_WriteSector() · RAW / No file system

Created with the Personal Edition of HelpNDoc: Transform Your Documentation Process with HelpNDoc's Project Analyzer