f_write

The f_write writes data to a file.

FRESULT f_write (
  FIL* FileObject,     // Pointer to the file object structure
  const BYTE* Buffer,  // Pointer to the data to be written
  WORD ByteToWrite,    // Number of bytes to write
  WORD* ByteWritten    // Pointer to the variable to return number of bytes written
);

Parameter

FileObject
Pointer to the valid file object structure.
Buffer
Pointer to the data to be written.
ByteToWrite
Specifies number of bytes to write.
ByteWritten
Pointer to the WORD variable to return number of bytes written.

Return Values

FR_OK
The function succeeded.
FR_DENIED
The function denied due to the file has been opened in read only mode.
FR_ALIGN_ERROR
The file has been opened in unbufferred mode but unaligned access was detected.
FR_RW_ERROR
Any error occured in low level disk I/O.
FR_NOT_READY
The disk drive cannot work due to no medium in the drive or any other reason.
FR_NOT_ENABLED
FatFs module has not been enabled.

Description

The read/write pointer increases in number of bytes written. The ByteWritten will be smaller than ByteToWrite when disk full or alignment error occured during write function. This function is not supported in read only configuration.

References

f_open, f_read, f_close, FIL

Return