SWRU368C May 2018 – January 2021 CC3100 , CC3100MOD , CC3200 , CC3200MOD
This operation enables opening of an existing file for either read or write. Upon opening request, the device checks that the file exists on the serial flash and if it doesn’t, an error is generated. Note that no size is configured as the size is allocated on file creation only.
_i32 sl_FsOpen (_u8 *pFileName,
_u32 AccessModeAndMaxSize,
_u32 *pToken,
_i32 *pFileHandle);
Type | Parameter | In/Out | Description |
---|---|---|---|
_u8* | pFileName | In | Pointer to the target file name. NULL terminated |
_u32 | AccessModeAndMaxSize | In | Size and flags as described below |
_u32* | pToken | In | Reserved for future use in secured file system. Should be NULL |
_i32* | pFileHandle | Out | Handle to the created file, in case success is returned |
AccessModeAndMaxSize can be configured using the following MACRO:
On success, zero is returned. On error, an error code is returned.
_u8 DeviceFileName[] = "MyFile.txt";
_i32 DeviceFileHandle = -1;
_i32 RetVal;
RetVal = sl_FsOpen(DeviceFileName,
FS_MODE_OPEN_READ,
NULL,
&DeviceFileHandle);
RetVal = sl_FsClose(DeviceFileHandle,
NULL,
NULL,
NULL );
RetVal = sl_FsOpen(DeviceFileName,
FS_MODE_OPEN_WRITE,
NULL,
&DeviceFileHandle);
RetVal = sl_FsClose(DeviceFileHandle,
NULL,
NULL,
NULL );