SWRU368C May 2018 – January 2021 CC3100 , CC3100MOD , CC3200 , CC3200MOD
This operation enables creation of a non-existing file. Upon creation request, the device checks for available space on the serial flash. Failing to allocate space for the new file generates an error. Additionally, creating an already existing file generates an error.
_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:
FS_MODE_OPEN_CREATE(maxSizeInBytes,accessModeFlags)
(((x*4096)- 512) % Granularity) * Granularity, where x is an integer and the supported granularities are {256, 1024, 4096, 16384, 65536}
On success, zero is returned. On error, an error code is returned.
_u8 DeviceFileName[] = "MyFile.txt";
_u32 MaxSize = 63 * 1024;
_i32 DeviceFileHandle = -1;
_i32 RetVal;
RetVal = sl_FsOpen(DeviceFileName,
FS_MODE_OPEN_CREATE(MaxSize , _FS_FILE_OPEN_FLAG_COMMIT ),
NULL,
&DeviceFileHandle);
RetVal = sl_FsClose(DeviceFileHandle,
NULL,
NULL,
NULL );