fixed drive strength

Dependents:   capstone_i2c

Fork of mbed-dev by mbed official

Committer:
<>
Date:
Tue Mar 14 16:40:56 2017 +0000
Revision:
160:d5399cc887bb
Parent:
149:156823d33999
This updates the lib to the mbed lib v138

Who changed what in which revision?

UserRevisionLine numberNew contents of line
<> 149:156823d33999 1 /* mbed Microcontroller Library
<> 149:156823d33999 2 * Copyright (c) 2006-2013 ARM Limited
<> 149:156823d33999 3 *
<> 149:156823d33999 4 * Licensed under the Apache License, Version 2.0 (the "License");
<> 149:156823d33999 5 * you may not use this file except in compliance with the License.
<> 149:156823d33999 6 * You may obtain a copy of the License at
<> 149:156823d33999 7 *
<> 149:156823d33999 8 * http://www.apache.org/licenses/LICENSE-2.0
<> 149:156823d33999 9 *
<> 149:156823d33999 10 * Unless required by applicable law or agreed to in writing, software
<> 149:156823d33999 11 * distributed under the License is distributed on an "AS IS" BASIS,
<> 149:156823d33999 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<> 149:156823d33999 13 * See the License for the specific language governing permissions and
<> 149:156823d33999 14 * limitations under the License.
<> 149:156823d33999 15 */
<> 149:156823d33999 16 #ifndef MBED_FILELIKE_H
<> 149:156823d33999 17 #define MBED_FILELIKE_H
<> 149:156823d33999 18
<> 160:d5399cc887bb 19 #include "platform/mbed_toolchain.h"
<> 149:156823d33999 20 #include "drivers/FileBase.h"
<> 149:156823d33999 21
<> 149:156823d33999 22 namespace mbed {
<> 149:156823d33999 23 /** \addtogroup drivers */
<> 149:156823d33999 24 /** @{*/
<> 149:156823d33999 25
<> 160:d5399cc887bb 26
<> 149:156823d33999 27 /* Class FileLike
<> 149:156823d33999 28 * A file-like object is one that can be opened with fopen by
<> 160:d5399cc887bb 29 * fopen("/name", mode).
<> 149:156823d33999 30 *
<> 149:156823d33999 31 * @Note Synchronization level: Set by subclass
<> 149:156823d33999 32 */
<> 160:d5399cc887bb 33 class FileLike : public FileBase {
<> 160:d5399cc887bb 34 public:
<> 160:d5399cc887bb 35 /** Constructor FileLike
<> 160:d5399cc887bb 36 *
<> 160:d5399cc887bb 37 * @param name The name to use to open the file.
<> 160:d5399cc887bb 38 */
<> 160:d5399cc887bb 39 FileLike(const char *name = NULL) : FileBase(name, FilePathType) {}
<> 160:d5399cc887bb 40 virtual ~FileLike() {}
<> 160:d5399cc887bb 41
<> 160:d5399cc887bb 42 /** Read the contents of a file into a buffer
<> 160:d5399cc887bb 43 *
<> 160:d5399cc887bb 44 * @param buffer The buffer to read in to
<> 160:d5399cc887bb 45 * @param size The number of bytes to read
<> 160:d5399cc887bb 46 * @return The number of bytes read, 0 at end of file, negative error on failure
<> 160:d5399cc887bb 47 */
<> 160:d5399cc887bb 48 virtual ssize_t read(void *buffer, size_t len) = 0;
<> 160:d5399cc887bb 49
<> 160:d5399cc887bb 50 /** Write the contents of a buffer to a file
<> 160:d5399cc887bb 51 *
<> 160:d5399cc887bb 52 * @param buffer The buffer to write from
<> 160:d5399cc887bb 53 * @param size The number of bytes to write
<> 160:d5399cc887bb 54 * @return The number of bytes written, negative error on failure
<> 160:d5399cc887bb 55 */
<> 160:d5399cc887bb 56 virtual ssize_t write(const void *buffer, size_t len) = 0;
<> 149:156823d33999 57
<> 160:d5399cc887bb 58 /** Close a file
<> 160:d5399cc887bb 59 *
<> 160:d5399cc887bb 60 * @return 0 on success, negative error code on failure
<> 160:d5399cc887bb 61 */
<> 160:d5399cc887bb 62 virtual int close() = 0;
<> 160:d5399cc887bb 63
<> 160:d5399cc887bb 64 /** Flush any buffers associated with the file
<> 160:d5399cc887bb 65 *
<> 160:d5399cc887bb 66 * @return 0 on success, negative error code on failure
<> 160:d5399cc887bb 67 */
<> 160:d5399cc887bb 68 virtual int sync() = 0;
<> 160:d5399cc887bb 69
<> 160:d5399cc887bb 70 /** Check if the file in an interactive terminal device
<> 160:d5399cc887bb 71 *
<> 160:d5399cc887bb 72 * @return True if the file is a terminal
<> 160:d5399cc887bb 73 */
<> 160:d5399cc887bb 74 virtual int isatty() = 0;
<> 160:d5399cc887bb 75
<> 160:d5399cc887bb 76 /** Move the file position to a given offset from from a given location
<> 160:d5399cc887bb 77 *
<> 160:d5399cc887bb 78 * @param offset The offset from whence to move to
<> 160:d5399cc887bb 79 * @param whence The start of where to seek
<> 160:d5399cc887bb 80 * SEEK_SET to start from beginning of file,
<> 160:d5399cc887bb 81 * SEEK_CUR to start from current position in file,
<> 160:d5399cc887bb 82 * SEEK_END to start from end of file
<> 160:d5399cc887bb 83 * @return The new offset of the file
<> 160:d5399cc887bb 84 */
<> 160:d5399cc887bb 85 virtual off_t seek(off_t offset, int whence = SEEK_SET) = 0;
<> 160:d5399cc887bb 86
<> 160:d5399cc887bb 87 /** Get the file position of the file
<> 149:156823d33999 88 *
<> 160:d5399cc887bb 89 * @return The current offset in the file
<> 160:d5399cc887bb 90 */
<> 160:d5399cc887bb 91 virtual off_t tell() = 0;
<> 160:d5399cc887bb 92
<> 160:d5399cc887bb 93 /** Rewind the file position to the beginning of the file
<> 160:d5399cc887bb 94 *
<> 160:d5399cc887bb 95 * @note This is equivalent to file_seek(file, 0, FS_SEEK_SET)
<> 160:d5399cc887bb 96 */
<> 160:d5399cc887bb 97 virtual void rewind() = 0;
<> 160:d5399cc887bb 98
<> 160:d5399cc887bb 99 /** Get the size of the file
<> 160:d5399cc887bb 100 *
<> 160:d5399cc887bb 101 * @return Size of the file in bytes
<> 160:d5399cc887bb 102 */
<> 160:d5399cc887bb 103 virtual size_t size() = 0;
<> 160:d5399cc887bb 104
<> 160:d5399cc887bb 105 /** Move the file position to a given offset from a given location.
<> 160:d5399cc887bb 106 *
<> 160:d5399cc887bb 107 * @param offset The offset from whence to move to
<> 160:d5399cc887bb 108 * @param whence SEEK_SET for the start of the file, SEEK_CUR for the
<> 160:d5399cc887bb 109 * current file position, or SEEK_END for the end of the file.
<> 160:d5399cc887bb 110 *
<> 160:d5399cc887bb 111 * @returns
<> 160:d5399cc887bb 112 * new file position on success,
<> 160:d5399cc887bb 113 * -1 on failure or unsupported
<> 149:156823d33999 114 */
<> 160:d5399cc887bb 115 MBED_DEPRECATED_SINCE("mbed-os-5.4", "Replaced by FileLike::seek")
<> 160:d5399cc887bb 116 virtual off_t lseek(off_t offset, int whence) { return seek(offset, whence); }
<> 160:d5399cc887bb 117
<> 160:d5399cc887bb 118 /** Flush any buffers associated with the FileHandle, ensuring it
<> 160:d5399cc887bb 119 * is up to date on disk
<> 160:d5399cc887bb 120 *
<> 160:d5399cc887bb 121 * @returns
<> 160:d5399cc887bb 122 * 0 on success or un-needed,
<> 160:d5399cc887bb 123 * -1 on error
<> 160:d5399cc887bb 124 */
<> 160:d5399cc887bb 125 MBED_DEPRECATED_SINCE("mbed-os-5.4", "Replaced by FileLike::sync")
<> 160:d5399cc887bb 126 virtual int fsync() { return sync(); }
<> 149:156823d33999 127
<> 160:d5399cc887bb 128 /** Find the length of the file
<> 160:d5399cc887bb 129 *
<> 160:d5399cc887bb 130 * @returns
<> 160:d5399cc887bb 131 * Length of the file
<> 160:d5399cc887bb 132 */
<> 160:d5399cc887bb 133 MBED_DEPRECATED_SINCE("mbed-os-5.4", "Replaced by FileLike::size")
<> 160:d5399cc887bb 134 virtual off_t flen() { return size(); }
<> 149:156823d33999 135
<> 160:d5399cc887bb 136 protected:
<> 160:d5399cc887bb 137 /** Acquire exclusive access to this object.
<> 160:d5399cc887bb 138 */
<> 160:d5399cc887bb 139 virtual void lock() {
<> 160:d5399cc887bb 140 // Stub
<> 160:d5399cc887bb 141 }
<> 160:d5399cc887bb 142
<> 160:d5399cc887bb 143 /** Release exclusive access to this object.
<> 160:d5399cc887bb 144 */
<> 160:d5399cc887bb 145 virtual void unlock() {
<> 160:d5399cc887bb 146 // Stub
<> 160:d5399cc887bb 147 }
<> 149:156823d33999 148 };
<> 149:156823d33999 149
<> 160:d5399cc887bb 150
<> 160:d5399cc887bb 151 /** @}*/
<> 149:156823d33999 152 } // namespace mbed
<> 149:156823d33999 153
<> 149:156823d33999 154 #endif