Download FreeRTOS

Quality RTOS & Embedded Software

New FreeRTOS Long Term Support version released
Simplifying Authenticated Cloud Connectivity for Any Device.
Designing an energy efficient and cloud-connected IoT solution with CoAP.
Introducing FreeRTOS Kernel version 11.0.0:
FreeRTOS Roadmap and Code Contribution process.


[FreeRTOS Embedded File System API]

long f_write( const void *pvBuffer, long lSize, long lItems, FILE_F pxFileHandle );

Writes data into an open FAT file in the fat file system. The data is written at the current file read/write position, and the current file read/write position is incremented by the number of bytes successfully written.

A file can only be written to if it was opened with one of the following option strings: "w", "w+", "a+", "r+" or "a" (see f_open()).


pvBuffer   A pointer to the source of the data being written to the file.

lSize,   The size in bytes of the item being written to the file.

lItems   The number of items being written to the file (the size of each item being set by the lSize parameter).

pxFileHandle   The handle of the file to which the data is being written. The handle is returned by the call to f_open() used to originally open the file.

Any value   The returned value is the number of items that were successfully written to the disk.

See also


Example usage:

void vSampleFunction( void )
F_FILE *pxFile;
char *pcString = "ABC";

/* Open the file afile.bin for writing. */
pxFile = f_open( "afile.bin", "w" );

if( pxFile != NULL )
/* Write three single characters to the opened file. */
if( f_write( pcString, 1, 3, pxFile ) == 3 )
/* All three bytes were written to the file. */

/* Close the file again. */
f_close( pxFile );

Example use of the f_write() API function
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.