Updated to use external spawn.

Fork of simplelink_V2 by David Fletcher

Committer:
dflet
Date:
Sat Jun 06 13:48:29 2015 +0000
Revision:
1:9b68e650b3f6
Parent:
0:1a07906111ec
Oppps

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dflet 0:1a07906111ec 1 /*
dflet 0:1a07906111ec 2 * fs.h - CC31xx/CC32xx Host Driver Implementation
dflet 0:1a07906111ec 3 *
dflet 0:1a07906111ec 4 * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
dflet 0:1a07906111ec 5 *
dflet 0:1a07906111ec 6 *
dflet 0:1a07906111ec 7 * Redistribution and use in source and binary forms, with or without
dflet 0:1a07906111ec 8 * modification, are permitted provided that the following conditions
dflet 0:1a07906111ec 9 * are met:
dflet 0:1a07906111ec 10 *
dflet 0:1a07906111ec 11 * Redistributions of source code must retain the above copyright
dflet 0:1a07906111ec 12 * notice, this list of conditions and the following disclaimer.
dflet 0:1a07906111ec 13 *
dflet 0:1a07906111ec 14 * Redistributions in binary form must reproduce the above copyright
dflet 0:1a07906111ec 15 * notice, this list of conditions and the following disclaimer in the
dflet 0:1a07906111ec 16 * documentation and/or other materials provided with the
dflet 0:1a07906111ec 17 * distribution.
dflet 0:1a07906111ec 18 *
dflet 0:1a07906111ec 19 * Neither the name of Texas Instruments Incorporated nor the names of
dflet 0:1a07906111ec 20 * its contributors may be used to endorse or promote products derived
dflet 0:1a07906111ec 21 * from this software without specific prior written permission.
dflet 0:1a07906111ec 22 *
dflet 0:1a07906111ec 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
dflet 0:1a07906111ec 24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
dflet 0:1a07906111ec 25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
dflet 0:1a07906111ec 26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
dflet 0:1a07906111ec 27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
dflet 0:1a07906111ec 28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
dflet 0:1a07906111ec 29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
dflet 0:1a07906111ec 30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
dflet 0:1a07906111ec 31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
dflet 0:1a07906111ec 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
dflet 0:1a07906111ec 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dflet 0:1a07906111ec 34 *
dflet 0:1a07906111ec 35 */
dflet 0:1a07906111ec 36
dflet 0:1a07906111ec 37 /*****************************************************************************/
dflet 0:1a07906111ec 38 /* Include files */
dflet 0:1a07906111ec 39 /*****************************************************************************/
dflet 0:1a07906111ec 40
dflet 0:1a07906111ec 41 #include "cc3100_simplelink.h"
dflet 0:1a07906111ec 42
dflet 0:1a07906111ec 43 #ifndef FS_H_
dflet 0:1a07906111ec 44 #define FS_H_
dflet 0:1a07906111ec 45
dflet 0:1a07906111ec 46 /*!
dflet 0:1a07906111ec 47
dflet 0:1a07906111ec 48 \addtogroup FileSystem
dflet 0:1a07906111ec 49 @{
dflet 0:1a07906111ec 50
dflet 0:1a07906111ec 51 */
dflet 0:1a07906111ec 52
dflet 0:1a07906111ec 53 /*****************************************************************************/
dflet 0:1a07906111ec 54 /* Macro declarations */
dflet 0:1a07906111ec 55 /*****************************************************************************/
dflet 0:1a07906111ec 56
dflet 0:1a07906111ec 57 /* FS error codes */
dflet 0:1a07906111ec 58 #define SL_FS_OK (0)
dflet 0:1a07906111ec 59 #define SL_FS_ERR_EMPTY_SFLASH (-67)
dflet 0:1a07906111ec 60 #define SL_FS_ERR_FILE_IS_NOT_SECURE_AND_SIGN (-66)
dflet 0:1a07906111ec 61 #define SL_FS_ERASING_FLASH (-65)
dflet 0:1a07906111ec 62 #define SL_FS_FILE_HAS_NOT_BEEN_CLOSE_CORRECTLY (-64)
dflet 0:1a07906111ec 63 #define SL_FS_WRONG_SIGNATURE (-63)
dflet 0:1a07906111ec 64 #define SL_FS_WRONG_SIGNATURE_OR_CERTIFIC_NAME_LENGTH (-62)
dflet 0:1a07906111ec 65 #define SL_FS_NOT_16_ALIGNED (-61)
dflet 0:1a07906111ec 66 #define SL_FS_CERT_CHAIN_ERROR (-60)
dflet 0:1a07906111ec 67 #define SL_FS_FILE_NAME_EXIST (-59)
dflet 0:1a07906111ec 68 #define SL_FS_SECURITY_BUF_ALREADY_ALLOC (-58)
dflet 0:1a07906111ec 69 #define SL_FS_SECURE_FILE_MUST_BE_COMMIT (-57)
dflet 0:1a07906111ec 70 #define SL_FS_ERR_INCORRECT_OFFSET_ALIGNMENT (-56)
dflet 0:1a07906111ec 71 #define SL_FS_ERR_FAILED_READ_NVMEM_HEADER (-55)
dflet 0:1a07906111ec 72 #define SL_FS_WRONG_FILE_NAME (-54)
dflet 0:1a07906111ec 73 #define SL_FS_FILE_SYSTEM_IS_LOCKED (-53)
dflet 0:1a07906111ec 74 #define SL_FS_SECURITY_ALLERT (-52)
dflet 0:1a07906111ec 75 #define SL_FS_FILE_UNVALID_FILE_SIZE (-51)
dflet 0:1a07906111ec 76 #define SL_FS_ERR_TOKEN_IS_NOT_VALID (-50)
dflet 0:1a07906111ec 77 #define SL_FS_NO_DEVICE_IS_LOADED (-49)
dflet 0:1a07906111ec 78 #define SL_FS_DATA_ADDRESS_SHOUD_BE_IN_DATA_RAM (-48)
dflet 0:1a07906111ec 79 #define SL_FS_DATA_IS_NOT_ALIGNED (-47)
dflet 0:1a07906111ec 80 #define SL_FS_ERR_OVERLAP_DETECTION_THRESHHOLD (-46)
dflet 0:1a07906111ec 81 #define SL_FS_FILE_HAS_RESERVED_NV_INDEX (-45)
dflet 0:1a07906111ec 82 #define SL_FS_ERR_MAX_FS_FILES_IS_LARGER (-44)
dflet 0:1a07906111ec 83 #define SL_FS_ERR_MAX_FS_FILES_IS_SMALLER (-43)
dflet 0:1a07906111ec 84 #define SL_FS_FILE_MAX_SIZE_EXCEEDED (-42)
dflet 0:1a07906111ec 85 #define SL_FS_INVALID_BUFFER_FOR_READ (-41)
dflet 0:1a07906111ec 86 #define SL_FS_INVALID_BUFFER_FOR_WRITE (-40)
dflet 0:1a07906111ec 87 #define SL_FS_ERR_FILE_IMAGE_IS_CORRUPTED (-39)
dflet 0:1a07906111ec 88 #define SL_FS_ERR_SIZE_OF_FILE_EXT_EXCEEDED (-38)
dflet 0:1a07906111ec 89 #define SL_FS_WARNING_FILE_NAME_NOT_KEPT (-37)
dflet 0:1a07906111ec 90 #define SL_FS_ERR_DEVICE_IS_NOT_FORMATTED (-36)
dflet 0:1a07906111ec 91 #define SL_FS_ERR_FAILED_WRITE_NVMEM_HEADER (-35)
dflet 0:1a07906111ec 92 #define SL_FS_ERR_NO_AVAILABLE_NV_INDEX (-34)
dflet 0:1a07906111ec 93 #define SL_FS_ERR_FAILED_TO_ALLOCATE_MEM (-33)
dflet 0:1a07906111ec 94 #define SL_FS_ERR_FAILED_TO_READ_INTEGRITY_HEADER_2 (-32)
dflet 0:1a07906111ec 95 #define SL_FS_ERR_FAILED_TO_READ_INTEGRITY_HEADER_1 (-31)
dflet 0:1a07906111ec 96 #define SL_FS_ERR_NO_AVAILABLE_BLOCKS (-30)
dflet 0:1a07906111ec 97 #define SL_FS_ERR_FILE_MAX_SIZE_BIGGER_THAN_EXISTING_FILE (-29)
dflet 0:1a07906111ec 98 #define SL_FS_ERR_FILE_EXISTS_ON_DIFFERENT_DEVICE_ID (-28)
dflet 0:1a07906111ec 99 #define SL_FS_ERR_INVALID_ACCESS_TYPE (-27)
dflet 0:1a07906111ec 100 #define SL_FS_ERR_FILE_ALREADY_EXISTS (-26)
dflet 0:1a07906111ec 101 #define SL_FS_ERR_PROGRAM (-25)
dflet 0:1a07906111ec 102 #define SL_FS_ERR_NO_ENTRIES_AVAILABLE (-24)
dflet 0:1a07906111ec 103 #define SL_FS_ERR_FILE_ACCESS_IS_DIFFERENT (-23)
dflet 0:1a07906111ec 104 #define SL_FS_ERR_BAD_FILE_MODE (-22)
dflet 0:1a07906111ec 105 #define SL_FS_ERR_FAILED_READ_NVFILE (-21)
dflet 0:1a07906111ec 106 #define SL_FS_ERR_FAILED_INIT_STORAGE (-20)
dflet 0:1a07906111ec 107 #define SL_FS_ERR_CONTINUE_WRITE_MUST_BE_MOD_4 (-19)
dflet 0:1a07906111ec 108 #define SL_FS_ERR_FAILED_LOAD_FILE (-18)
dflet 0:1a07906111ec 109 #define SL_FS_ERR_INVALID_HANDLE (-17)
dflet 0:1a07906111ec 110 #define SL_FS_ERR_FAILED_TO_WRITE (-16)
dflet 0:1a07906111ec 111 #define SL_FS_ERR_OFFSET_OUT_OF_RANGE (-15)
dflet 0:1a07906111ec 112 #define SL_FS_ERR_ALLOC (-14)
dflet 0:1a07906111ec 113 #define SL_FS_ERR_READ_DATA_LENGTH (-13)
dflet 0:1a07906111ec 114 #define SL_FS_ERR_INVALID_FILE_ID (-12)
dflet 0:1a07906111ec 115 #define SL_FS_ERR_FILE_NOT_EXISTS (-11)
dflet 0:1a07906111ec 116 #define SL_FS_ERR_EMPTY_ERROR (-10)
dflet 0:1a07906111ec 117 #define SL_FS_ERR_INVALID_ARGS (-9)
dflet 0:1a07906111ec 118 #define SL_FS_ERR_FAILED_TO_CREATE_FILE (-8)
dflet 0:1a07906111ec 119 #define SL_FS_ERR_FS_ALREADY_LOADED (-7)
dflet 0:1a07906111ec 120 #define SL_FS_ERR_UNKNOWN (-6)
dflet 0:1a07906111ec 121 #define SL_FS_ERR_FAILED_TO_CREATE_LOCK_OBJ (-5)
dflet 0:1a07906111ec 122 #define SL_FS_ERR_DEVICE_NOT_LOADED (-4)
dflet 0:1a07906111ec 123 #define SL_FS_ERR_INVALID_MAGIC_NUM (-3)
dflet 0:1a07906111ec 124 #define SL_FS_ERR_FAILED_TO_READ (-2)
dflet 0:1a07906111ec 125 #define SL_FS_ERR_NOT_SUPPORTED (-1)
dflet 0:1a07906111ec 126 /* end of error codes */
dflet 0:1a07906111ec 127
dflet 0:1a07906111ec 128 #define _FS_MODE_ACCESS_RESERVED_OFFSET (24)
dflet 0:1a07906111ec 129 #define _FS_MODE_ACCESS_RESERVED_MASK (0xFF)
dflet 0:1a07906111ec 130 #define _FS_MODE_ACCESS_FLAGS_OFFSET (16)
dflet 0:1a07906111ec 131 #define _FS_MODE_ACCESS_FLAGS_MASK (0xFF)
dflet 0:1a07906111ec 132 #define _FS_MODE_ACCESS_OFFSET (12)
dflet 0:1a07906111ec 133 #define _FS_MODE_ACCESS_MASK (0xF)
dflet 0:1a07906111ec 134 #define _FS_MODE_OPEN_SIZE_GRAN_OFFSET (8)
dflet 0:1a07906111ec 135 #define _FS_MODE_OPEN_SIZE_GRAN_MASK (0xF)
dflet 0:1a07906111ec 136 #define _FS_MODE_OPEN_SIZE_OFFSET (0)
dflet 0:1a07906111ec 137 #define _FS_MODE_OPEN_SIZE_MASK (0xFF)
dflet 0:1a07906111ec 138 #define MAX_MODE_SIZE (0xFF)
dflet 0:1a07906111ec 139 #define _FS_MODE(Access, SizeGran, Size,Flags) (uint32_t)(((uint32_t)((Access) & _FS_MODE_ACCESS_MASK)<<_FS_MODE_ACCESS_OFFSET) | \
dflet 0:1a07906111ec 140 ((uint32_t)((SizeGran) & _FS_MODE_OPEN_SIZE_GRAN_MASK)<<_FS_MODE_OPEN_SIZE_GRAN_OFFSET) | \
dflet 0:1a07906111ec 141 ((uint32_t)((Size) & _FS_MODE_OPEN_SIZE_MASK)<<_FS_MODE_OPEN_SIZE_OFFSET) | \
dflet 0:1a07906111ec 142 ((uint32_t)((Flags) & _FS_MODE_ACCESS_FLAGS_MASK)<<_FS_MODE_ACCESS_FLAGS_OFFSET))
dflet 0:1a07906111ec 143
dflet 0:1a07906111ec 144
dflet 0:1a07906111ec 145 /* sl_FsOpen options */
dflet 0:1a07906111ec 146 /* Open for Read */
dflet 0:1a07906111ec 147 #define FS_MODE_OPEN_READ _FS_MODE(_FS_MODE_OPEN_READ,0,0,0)
dflet 0:1a07906111ec 148 /* Open for Write (in case file exist) */
dflet 0:1a07906111ec 149 #define FS_MODE_OPEN_WRITE _FS_MODE(_FS_MODE_OPEN_WRITE,0,0,0)
dflet 0:1a07906111ec 150 /* Open for Creating a new file */
dflet 0:1a07906111ec 151 #define FS_MODE_OPEN_CREATE(maxSizeInBytes,accessModeFlags) _sl_GetCreateFsMode(maxSizeInBytes,accessModeFlags)
dflet 0:1a07906111ec 152
dflet 0:1a07906111ec 153 namespace mbed_cc3100 {
dflet 0:1a07906111ec 154
dflet 0:1a07906111ec 155 /*****************************************************************************/
dflet 0:1a07906111ec 156 /* Structure/Enum declarations */
dflet 0:1a07906111ec 157 /*****************************************************************************/
dflet 0:1a07906111ec 158 typedef struct {
dflet 0:1a07906111ec 159 uint16_t flags;
dflet 0:1a07906111ec 160 uint32_t FileLen;
dflet 0:1a07906111ec 161 uint32_t AllocatedLen;
dflet 0:1a07906111ec 162 uint32_t Token[4];
dflet 0:1a07906111ec 163 } SlFsFileInfo_t;
dflet 0:1a07906111ec 164
dflet 0:1a07906111ec 165 typedef enum {
dflet 0:1a07906111ec 166 _FS_MODE_OPEN_READ = 0,
dflet 0:1a07906111ec 167 _FS_MODE_OPEN_WRITE,
dflet 0:1a07906111ec 168 _FS_MODE_OPEN_CREATE,
dflet 0:1a07906111ec 169 _FS_MODE_OPEN_WRITE_CREATE_IF_NOT_EXIST
dflet 0:1a07906111ec 170 } SlFsFileOpenAccessType_e;
dflet 0:1a07906111ec 171
dflet 0:1a07906111ec 172 typedef enum {
dflet 0:1a07906111ec 173 _FS_FILE_OPEN_FLAG_COMMIT = 0x1, /* MIRROR - for fail safe */
dflet 0:1a07906111ec 174 _FS_FILE_OPEN_FLAG_SECURE = 0x2, /* SECURE */
dflet 0:1a07906111ec 175 _FS_FILE_OPEN_FLAG_NO_SIGNATURE_TEST = 0x4, /* Relevant to secure file only */
dflet 0:1a07906111ec 176 _FS_FILE_OPEN_FLAG_STATIC = 0x8, /* Relevant to secure file only */
dflet 0:1a07906111ec 177 _FS_FILE_OPEN_FLAG_VENDOR = 0x10, /* Relevant to secure file only */
dflet 0:1a07906111ec 178 _FS_FILE_PUBLIC_WRITE= 0x20, /* Relevant to secure file only, the file can be opened for write without Token */
dflet 0:1a07906111ec 179 _FS_FILE_PUBLIC_READ = 0x40 /* Relevant to secure file only, the file can be opened for read without Token */
dflet 0:1a07906111ec 180 } SlFileOpenFlags_e;
dflet 0:1a07906111ec 181
dflet 0:1a07906111ec 182 typedef enum {
dflet 0:1a07906111ec 183 _FS_MODE_SIZE_GRAN_256B = 0, /* MAX_SIZE = 64K */
dflet 0:1a07906111ec 184 _FS_MODE_SIZE_GRAN_1KB, /* MAX_SIZE = 256K */
dflet 0:1a07906111ec 185 _FS_MODE_SIZE_GRAN_4KB, /* MAX_SZIE = 1M */
dflet 0:1a07906111ec 186 _FS_MODE_SIZE_GRAN_16KB, /* MAX_SIZE = 4M */
dflet 0:1a07906111ec 187 _FS_MODE_SIZE_GRAN_64KB, /* MAX_SIZE = 16M */
dflet 0:1a07906111ec 188 _FS_MAX_MODE_SIZE_GRAN
dflet 0:1a07906111ec 189 } _SlFsFileOpenMaxSizeGran_e;
dflet 0:1a07906111ec 190
dflet 0:1a07906111ec 191 class cc3100_driver;
dflet 0:1a07906111ec 192
dflet 0:1a07906111ec 193 class cc3100_fs
dflet 0:1a07906111ec 194 {
dflet 0:1a07906111ec 195
dflet 0:1a07906111ec 196 public:
dflet 0:1a07906111ec 197
dflet 0:1a07906111ec 198 cc3100_fs(cc3100_driver &driver);
dflet 0:1a07906111ec 199
dflet 0:1a07906111ec 200 ~cc3100_fs();
dflet 0:1a07906111ec 201
dflet 0:1a07906111ec 202 /*****************************************************************************/
dflet 0:1a07906111ec 203 /* Internal Function prototypes */
dflet 0:1a07906111ec 204 /*****************************************************************************/
dflet 0:1a07906111ec 205 uint32_t _sl_GetCreateFsMode(uint32_t maxSizeInBytes,uint32_t accessFlags);
dflet 0:1a07906111ec 206 uint16_t _sl_Strlen(const uint8_t *buffer);
dflet 0:1a07906111ec 207
dflet 0:1a07906111ec 208 /*****************************************************************************/
dflet 0:1a07906111ec 209 /* Function prototypes */
dflet 0:1a07906111ec 210 /*****************************************************************************/
dflet 0:1a07906111ec 211
dflet 0:1a07906111ec 212 /*!
dflet 0:1a07906111ec 213 \brief open file for read or write from/to storage device
dflet 0:1a07906111ec 214
dflet 0:1a07906111ec 215 \param[in] pFileName File Name buffer pointer
dflet 0:1a07906111ec 216 \param[in] AccessModeAndMaxSize Options: As described below
dflet 0:1a07906111ec 217 \param[in] pToken Reserved for future use. Use NULL for this field
dflet 0:1a07906111ec 218 \param[out] pFileHandle Pointing on the file and used for read and write commands to the file
dflet 0:1a07906111ec 219
dflet 0:1a07906111ec 220 AccessModeAndMaxSize possible input \n
dflet 0:1a07906111ec 221 FS_MODE_OPEN_READ - Read a file \n
dflet 0:1a07906111ec 222 FS_MODE_OPEN_WRITE - Open for write for an existing file \n
dflet 0:1a07906111ec 223 FS_MODE_OPEN_CREATE(maxSizeInBytes,accessModeFlags) - Open for creating a new file. Max file size is defined in bytes. \n
dflet 0:1a07906111ec 224 For optimal FS size, use max size in 4K-512 bytes steps (e.g. 3584,7680,117760) \n
dflet 0:1a07906111ec 225 Several access modes bits can be combined together from SlFileOpenFlags_e enum
dflet 0:1a07906111ec 226
dflet 0:1a07906111ec 227 \return On success, zero is returned. On error, an error code is returned
dflet 0:1a07906111ec 228
dflet 0:1a07906111ec 229 \sa sl_FsRead sl_FsWrite sl_FsClose
dflet 0:1a07906111ec 230 \note belongs to \ref basic_api
dflet 0:1a07906111ec 231 \warning
dflet 0:1a07906111ec 232 \par Example:
dflet 0:1a07906111ec 233 \code
dflet 0:1a07906111ec 234 char* DeviceFileName = "MyFile.txt";
dflet 0:1a07906111ec 235 unsigned long MaxSize = 63 * 1024; //62.5K is max file size
dflet 0:1a07906111ec 236 long DeviceFileHandle = -1;
dflet 0:1a07906111ec 237 long RetVal; //negative retval is an error
dflet 0:1a07906111ec 238 unsigned long Offset = 0;
dflet 0:1a07906111ec 239 uint8_t InputBuffer[100];
dflet 0:1a07906111ec 240
dflet 0:1a07906111ec 241 // Create a file and write data. The file in this example is secured, without signature and with a fail safe commit
dflet 0:1a07906111ec 242 RetVal = sl_FsOpen((uint8_t *)DeviceFileName,
dflet 0:1a07906111ec 243 FS_MODE_OPEN_CREATE(MaxSize , _FS_FILE_OPEN_FLAG_NO_SIGNATURE_TEST | _FS_FILE_OPEN_FLAG_COMMIT ),
dflet 0:1a07906111ec 244 NULL, &DeviceFileHandle);
dflet 0:1a07906111ec 245
dflet 0:1a07906111ec 246 Offset = 0;
dflet 0:1a07906111ec 247 //Preferred in secure file that the Offset and the length will be aligned to 16 bytes.
dflet 0:1a07906111ec 248 RetVal = sl_FsWrite( DeviceFileHandle, Offset, (uint8_t *)"HelloWorld", strlen("HelloWorld"));
dflet 0:1a07906111ec 249
dflet 0:1a07906111ec 250 RetVal = sl_FsClose(DeviceFileHandle, NULL, NULL , 0);
dflet 0:1a07906111ec 251
dflet 0:1a07906111ec 252 // open the same file for read, using the Token we got from the creation procedure above
dflet 0:1a07906111ec 253 RetVal = sl_FsOpen((uint8_t *)DeviceFileName,
dflet 0:1a07906111ec 254 FS_MODE_OPEN_READ,
dflet 0:1a07906111ec 255 NULL, &DeviceFileHandle);
dflet 0:1a07906111ec 256
dflet 0:1a07906111ec 257 Offset = 0;
dflet 0:1a07906111ec 258 RetVal = sl_FsRead( DeviceFileHandle, Offset, (uint8_t *)InputBuffer, strlen("HelloWorld"));
dflet 0:1a07906111ec 259
dflet 0:1a07906111ec 260 RetVal = sl_FsClose(DeviceFileHandle, NULL, NULL , 0);
dflet 0:1a07906111ec 261
dflet 0:1a07906111ec 262 \endcode
dflet 0:1a07906111ec 263 */
dflet 0:1a07906111ec 264 #if _SL_INCLUDE_FUNC(sl_FsOpen)
dflet 0:1a07906111ec 265 int32_t sl_FsOpen(const uint8_t *pFileName, const uint32_t AccessModeAndMaxSize,uint32_t *pToken,int32_t *pFileHandle);
dflet 0:1a07906111ec 266 #endif
dflet 0:1a07906111ec 267
dflet 0:1a07906111ec 268 /*!
dflet 0:1a07906111ec 269 \brief close file in storage device
dflet 0:1a07906111ec 270
dflet 0:1a07906111ec 271 \param[in] FileHdl Pointer to the file (assigned from sl_FsOpen)
dflet 0:1a07906111ec 272 \param[in] pCeritificateFileName Reserved for future use. Use NULL.
dflet 0:1a07906111ec 273 \param[in] pSignature Reserved for future use. Use NULL.
dflet 0:1a07906111ec 274 \param[in] SignatureLen Reserved for future use. Use 0.
dflet 0:1a07906111ec 275
dflet 0:1a07906111ec 276
dflet 0:1a07906111ec 277 \return On success, zero is returned. On error, an error code is returned
dflet 0:1a07906111ec 278
dflet 0:1a07906111ec 279 \sa sl_FsRead sl_FsWrite sl_FsOpen
dflet 0:1a07906111ec 280 \note Call the fs_Close with signature = 'A' signature len = 1 for activating an abort action
dflet 0:1a07906111ec 281 \warning
dflet 0:1a07906111ec 282 \par Example:
dflet 0:1a07906111ec 283 \code
dflet 0:1a07906111ec 284 sl_FsClose(FileHandle,0,0,0);
dflet 0:1a07906111ec 285 \endcode
dflet 0:1a07906111ec 286 */
dflet 0:1a07906111ec 287 #if _SL_INCLUDE_FUNC(sl_FsClose)
dflet 0:1a07906111ec 288 int16_t sl_FsClose(const int32_t FileHdl, const uint8_t* pCeritificateFileName, const uint8_t* pSignature, const uint32_t SignatureLen);
dflet 0:1a07906111ec 289 #endif
dflet 0:1a07906111ec 290
dflet 0:1a07906111ec 291 /*!
dflet 0:1a07906111ec 292 \brief Read block of data from a file in storage device
dflet 0:1a07906111ec 293
dflet 0:1a07906111ec 294 \param[in] FileHdl Pointer to the file (assigned from sl_FsOpen)
dflet 0:1a07906111ec 295 \param[in] Offset Offset to specific read block
dflet 0:1a07906111ec 296 \param[out] pData Pointer for the received data
dflet 0:1a07906111ec 297 \param[in] Len Length of the received data
dflet 0:1a07906111ec 298
dflet 0:1a07906111ec 299 \return On success, returns the number of read bytes. On error, negative number is returned
dflet 0:1a07906111ec 300
dflet 0:1a07906111ec 301 \sa sl_FsClose sl_FsWrite sl_FsOpen
dflet 0:1a07906111ec 302 \note belongs to \ref basic_api
dflet 0:1a07906111ec 303 \warning
dflet 0:1a07906111ec 304 \par Example:
dflet 0:1a07906111ec 305 \code
dflet 0:1a07906111ec 306 Status = sl_FsRead(FileHandle, 0, &readBuff[0], readSize);
dflet 0:1a07906111ec 307 \endcode
dflet 0:1a07906111ec 308 */
dflet 0:1a07906111ec 309 #if _SL_INCLUDE_FUNC(sl_FsRead)
dflet 0:1a07906111ec 310 int32_t sl_FsRead(const int32_t FileHdl,uint32_t Offset ,uint8_t* pData,uint32_t Len);
dflet 0:1a07906111ec 311 #endif
dflet 0:1a07906111ec 312
dflet 0:1a07906111ec 313 /*!
dflet 0:1a07906111ec 314 \brief write block of data to a file in storage device
dflet 0:1a07906111ec 315
dflet 0:1a07906111ec 316 \param[in] FileHdl Pointer to the file (assigned from sl_FsOpen)
dflet 0:1a07906111ec 317 \param[in] Offset Offset to specific block to be written
dflet 0:1a07906111ec 318 \param[in] pData Pointer the transmitted data to the storage device
dflet 0:1a07906111ec 319 \param[in] Len Length of the transmitted data
dflet 0:1a07906111ec 320
dflet 0:1a07906111ec 321 \return On success, returns the number of written bytes. On error, an error code is returned
dflet 0:1a07906111ec 322
dflet 0:1a07906111ec 323 \sa
dflet 0:1a07906111ec 324 \note belongs to \ref basic_api
dflet 0:1a07906111ec 325 \warning
dflet 0:1a07906111ec 326 \par Example:
dflet 0:1a07906111ec 327 \code
dflet 0:1a07906111ec 328 Status = sl_FsWrite(FileHandle, 0, &buff[0], readSize);
dflet 0:1a07906111ec 329 \endcode
dflet 0:1a07906111ec 330 */
dflet 0:1a07906111ec 331 #if _SL_INCLUDE_FUNC(sl_FsWrite)
dflet 0:1a07906111ec 332 int32_t sl_FsWrite(const int32_t FileHdl,uint32_t Offset,uint8_t* pData,uint32_t Len);
dflet 0:1a07906111ec 333 #endif
dflet 0:1a07906111ec 334
dflet 0:1a07906111ec 335 /*!
dflet 0:1a07906111ec 336 \brief get info on a file
dflet 0:1a07906111ec 337
dflet 0:1a07906111ec 338 \param[in] pFileName File name
dflet 0:1a07906111ec 339 \param[in] Token Reserved for future use. Use 0
dflet 0:1a07906111ec 340 \param[out] pFsFileInfo Returns the File's Information: flags,file size, allocated size and Tokens
dflet 0:1a07906111ec 341
dflet 0:1a07906111ec 342 \return On success, zero is returned. On error, an error code is returned
dflet 0:1a07906111ec 343
dflet 0:1a07906111ec 344 \sa sl_FsOpen
dflet 0:1a07906111ec 345 \note belongs to \ref basic_api
dflet 0:1a07906111ec 346 \warning
dflet 0:1a07906111ec 347 \par Example:
dflet 0:1a07906111ec 348 \code
dflet 0:1a07906111ec 349 Status = sl_FsGetInfo("FileName.html",0,&FsFileInfo);
dflet 0:1a07906111ec 350 \endcode
dflet 0:1a07906111ec 351 */
dflet 0:1a07906111ec 352 #if _SL_INCLUDE_FUNC(sl_FsGetInfo)
dflet 0:1a07906111ec 353 int16_t sl_FsGetInfo(const uint8_t *pFileName, const uint32_t Token,SlFsFileInfo_t* pFsFileInfo);
dflet 0:1a07906111ec 354 #endif
dflet 0:1a07906111ec 355
dflet 0:1a07906111ec 356 /*!
dflet 0:1a07906111ec 357 \brief Delete specific file from a storage or all files from a storage (format)
dflet 0:1a07906111ec 358
dflet 0:1a07906111ec 359 \param[in] pFileName File Name
dflet 0:1a07906111ec 360 \param[in] Token Reserved for future use. Use 0
dflet 0:1a07906111ec 361 \return On success, zero is returned. On error, an error code is returned
dflet 0:1a07906111ec 362
dflet 0:1a07906111ec 363 \sa
dflet 0:1a07906111ec 364 \note belongs to \ref basic_api
dflet 0:1a07906111ec 365 \warning
dflet 0:1a07906111ec 366 \par Example:
dflet 0:1a07906111ec 367 \code
dflet 0:1a07906111ec 368 Status = sl_FsDel("FileName.html",0);
dflet 0:1a07906111ec 369 \endcode
dflet 0:1a07906111ec 370 */
dflet 0:1a07906111ec 371 #if _SL_INCLUDE_FUNC(sl_FsDel)
dflet 0:1a07906111ec 372 int16_t sl_FsDel(const uint8_t *pFileName, const uint32_t Token);
dflet 0:1a07906111ec 373 #endif
dflet 0:1a07906111ec 374
dflet 0:1a07906111ec 375 private:
dflet 0:1a07906111ec 376
dflet 0:1a07906111ec 377 cc3100_driver &_driver;
dflet 0:1a07906111ec 378
dflet 0:1a07906111ec 379 };//class
dflet 0:1a07906111ec 380
dflet 0:1a07906111ec 381 }//namespace mbed_cc3100
dflet 0:1a07906111ec 382
dflet 0:1a07906111ec 383 /*!
dflet 0:1a07906111ec 384
dflet 0:1a07906111ec 385 Close the Doxygen group.
dflet 0:1a07906111ec 386 @}
dflet 0:1a07906111ec 387
dflet 0:1a07906111ec 388 */
dflet 0:1a07906111ec 389
dflet 0:1a07906111ec 390 #endif /* __FS_H__ */
dflet 0:1a07906111ec 391
dflet 0:1a07906111ec 392