5.2.1 - Updated I2C files

Dependents:   mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510

Committer:
group-onsemi
Date:
Wed Jan 25 20:34:15 2017 +0000
Revision:
0:098463de4c5d
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
group-onsemi 0:098463de4c5d 1 /* mbed Microcontroller Library
group-onsemi 0:098463de4c5d 2 * Copyright (c) 2006-2013 ARM Limited
group-onsemi 0:098463de4c5d 3 *
group-onsemi 0:098463de4c5d 4 * Licensed under the Apache License, Version 2.0 (the "License");
group-onsemi 0:098463de4c5d 5 * you may not use this file except in compliance with the License.
group-onsemi 0:098463de4c5d 6 * You may obtain a copy of the License at
group-onsemi 0:098463de4c5d 7 *
group-onsemi 0:098463de4c5d 8 * http://www.apache.org/licenses/LICENSE-2.0
group-onsemi 0:098463de4c5d 9 *
group-onsemi 0:098463de4c5d 10 * Unless required by applicable law or agreed to in writing, software
group-onsemi 0:098463de4c5d 11 * distributed under the License is distributed on an "AS IS" BASIS,
group-onsemi 0:098463de4c5d 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
group-onsemi 0:098463de4c5d 13 * See the License for the specific language governing permissions and
group-onsemi 0:098463de4c5d 14 * limitations under the License.
group-onsemi 0:098463de4c5d 15 */
group-onsemi 0:098463de4c5d 16 #ifndef MBED_FILESYSTEMLIKE_H
group-onsemi 0:098463de4c5d 17 #define MBED_FILESYSTEMLIKE_H
group-onsemi 0:098463de4c5d 18
group-onsemi 0:098463de4c5d 19 #include "platform/platform.h"
group-onsemi 0:098463de4c5d 20
group-onsemi 0:098463de4c5d 21 #include "drivers/FileBase.h"
group-onsemi 0:098463de4c5d 22 #include "drivers/FileHandle.h"
group-onsemi 0:098463de4c5d 23 #include "drivers/DirHandle.h"
group-onsemi 0:098463de4c5d 24
group-onsemi 0:098463de4c5d 25 namespace mbed {
group-onsemi 0:098463de4c5d 26 /** \addtogroup drivers */
group-onsemi 0:098463de4c5d 27 /** @{*/
group-onsemi 0:098463de4c5d 28
group-onsemi 0:098463de4c5d 29 /** A filesystem-like object is one that can be used to open files
group-onsemi 0:098463de4c5d 30 * though it by fopen("/name/filename", mode)
group-onsemi 0:098463de4c5d 31 *
group-onsemi 0:098463de4c5d 32 * Implementations must define at least open (the default definitions
group-onsemi 0:098463de4c5d 33 * of the rest of the functions just return error values).
group-onsemi 0:098463de4c5d 34 *
group-onsemi 0:098463de4c5d 35 * @Note Synchronization level: Set by subclass
group-onsemi 0:098463de4c5d 36 */
group-onsemi 0:098463de4c5d 37 class FileSystemLike : public FileBase {
group-onsemi 0:098463de4c5d 38
group-onsemi 0:098463de4c5d 39 public:
group-onsemi 0:098463de4c5d 40 /** FileSystemLike constructor
group-onsemi 0:098463de4c5d 41 *
group-onsemi 0:098463de4c5d 42 * @param name The name to use for the filesystem.
group-onsemi 0:098463de4c5d 43 */
group-onsemi 0:098463de4c5d 44 FileSystemLike(const char *name);
group-onsemi 0:098463de4c5d 45
group-onsemi 0:098463de4c5d 46 virtual ~FileSystemLike();
group-onsemi 0:098463de4c5d 47
group-onsemi 0:098463de4c5d 48 static DirHandle *opendir();
group-onsemi 0:098463de4c5d 49 friend class BaseDirHandle;
group-onsemi 0:098463de4c5d 50
group-onsemi 0:098463de4c5d 51 /** Opens a file from the filesystem
group-onsemi 0:098463de4c5d 52 *
group-onsemi 0:098463de4c5d 53 * @param filename The name of the file to open.
group-onsemi 0:098463de4c5d 54 * @param flags One of O_RDONLY, O_WRONLY, or O_RDWR, OR'd with
group-onsemi 0:098463de4c5d 55 * zero or more of O_CREAT, O_TRUNC, or O_APPEND.
group-onsemi 0:098463de4c5d 56 *
group-onsemi 0:098463de4c5d 57 * @returns
group-onsemi 0:098463de4c5d 58 * A pointer to a FileHandle object representing the
group-onsemi 0:098463de4c5d 59 * file on success, or NULL on failure.
group-onsemi 0:098463de4c5d 60 */
group-onsemi 0:098463de4c5d 61 virtual FileHandle *open(const char *filename, int flags) = 0;
group-onsemi 0:098463de4c5d 62
group-onsemi 0:098463de4c5d 63 /** Remove a file from the filesystem.
group-onsemi 0:098463de4c5d 64 *
group-onsemi 0:098463de4c5d 65 * @param filename the name of the file to remove.
group-onsemi 0:098463de4c5d 66 * @param returns 0 on success, -1 on failure.
group-onsemi 0:098463de4c5d 67 */
group-onsemi 0:098463de4c5d 68 virtual int remove(const char *filename) { (void) filename; return -1; };
group-onsemi 0:098463de4c5d 69
group-onsemi 0:098463de4c5d 70 /** Rename a file in the filesystem.
group-onsemi 0:098463de4c5d 71 *
group-onsemi 0:098463de4c5d 72 * @param oldname the name of the file to rename.
group-onsemi 0:098463de4c5d 73 * @param newname the name to rename it to.
group-onsemi 0:098463de4c5d 74 *
group-onsemi 0:098463de4c5d 75 * @returns
group-onsemi 0:098463de4c5d 76 * 0 on success,
group-onsemi 0:098463de4c5d 77 * -1 on failure.
group-onsemi 0:098463de4c5d 78 */
group-onsemi 0:098463de4c5d 79 virtual int rename(const char *oldname, const char *newname) { (void) oldname, (void) newname; return -1; };
group-onsemi 0:098463de4c5d 80
group-onsemi 0:098463de4c5d 81 /** Opens a directory in the filesystem and returns a DirHandle
group-onsemi 0:098463de4c5d 82 * representing the directory stream.
group-onsemi 0:098463de4c5d 83 *
group-onsemi 0:098463de4c5d 84 * @param name The name of the directory to open.
group-onsemi 0:098463de4c5d 85 *
group-onsemi 0:098463de4c5d 86 * @returns
group-onsemi 0:098463de4c5d 87 * A DirHandle representing the directory stream, or
group-onsemi 0:098463de4c5d 88 * NULL on failure.
group-onsemi 0:098463de4c5d 89 */
group-onsemi 0:098463de4c5d 90 virtual DirHandle *opendir(const char *name) { (void) name; return NULL; };
group-onsemi 0:098463de4c5d 91
group-onsemi 0:098463de4c5d 92 /** Creates a directory in the filesystem.
group-onsemi 0:098463de4c5d 93 *
group-onsemi 0:098463de4c5d 94 * @param name The name of the directory to create.
group-onsemi 0:098463de4c5d 95 * @param mode The permissions to create the directory with.
group-onsemi 0:098463de4c5d 96 *
group-onsemi 0:098463de4c5d 97 * @returns
group-onsemi 0:098463de4c5d 98 * 0 on success,
group-onsemi 0:098463de4c5d 99 * -1 on failure.
group-onsemi 0:098463de4c5d 100 */
group-onsemi 0:098463de4c5d 101 virtual int mkdir(const char *name, mode_t mode) { (void) name, (void) mode; return -1; }
group-onsemi 0:098463de4c5d 102
group-onsemi 0:098463de4c5d 103 // TODO other filesystem functions (mkdir, rm, rn, ls etc)
group-onsemi 0:098463de4c5d 104 };
group-onsemi 0:098463de4c5d 105
group-onsemi 0:098463de4c5d 106 } // namespace mbed
group-onsemi 0:098463de4c5d 107
group-onsemi 0:098463de4c5d 108 #endif
group-onsemi 0:098463de4c5d 109
group-onsemi 0:098463de4c5d 110 /** @}*/