Update revision to use TI's mqtt and Freertos.

Dependencies:   mbed client server

Fork of cc3100_Test_mqtt_CM3 by David Fletcher

Committer:
dflet
Date:
Thu Sep 03 14:02:37 2015 +0000
Revision:
3:a8c249046181
SPI Mode change 1 to 0

Who changed what in which revision?

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