The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
<>
Date:
Tue Mar 14 16:20:51 2017 +0000
Revision:
138:093f2bd7b9eb
Parent:
128:9bcdf88f62b0
Release 138 of the mbed library

Ports for Upcoming Targets


Fixes and Changes

3716: fix for issue #3715: correction in startup files for ARM and IAR, alignment of system_stm32f429xx.c files https://github.com/ARMmbed/mbed-os/pull/3716
3741: STM32 remove warning in hal_tick_32b.c file https://github.com/ARMmbed/mbed-os/pull/3741
3780: STM32L4 : Fix GPIO G port compatibility https://github.com/ARMmbed/mbed-os/pull/3780
3831: NCS36510: SPISLAVE enabled (Conflict resolved) https://github.com/ARMmbed/mbed-os/pull/3831
3836: Allow to redefine nRF's PSTORAGE_NUM_OF_PAGES outside of the mbed-os https://github.com/ARMmbed/mbed-os/pull/3836
3840: STM32: gpio SPEED - always set High Speed by default https://github.com/ARMmbed/mbed-os/pull/3840
3844: STM32 GPIO: Typo correction. Update comment (GPIO_IP_WITHOUT_BRR) https://github.com/ARMmbed/mbed-os/pull/3844
3850: STM32: change spi error to debug warning https://github.com/ARMmbed/mbed-os/pull/3850
3860: Define GPIO_IP_WITHOUT_BRR for xDot platform https://github.com/ARMmbed/mbed-os/pull/3860
3880: DISCO_F469NI: allow the use of CAN2 instance when CAN1 is not activated https://github.com/ARMmbed/mbed-os/pull/3880
3795: Fix pwm period calc https://github.com/ARMmbed/mbed-os/pull/3795
3828: STM32 CAN API: correct format and type https://github.com/ARMmbed/mbed-os/pull/3828
3842: TARGET_NRF: corrected spi_init() to properly handle re-initialization https://github.com/ARMmbed/mbed-os/pull/3842
3843: STM32L476xG: set APB2 clock to 80MHz (instead of 40MHz) https://github.com/ARMmbed/mbed-os/pull/3843
3879: NUCLEO_F446ZE: Add missing AnalogIn pins on PF_3, PF_5 and PF_10. https://github.com/ARMmbed/mbed-os/pull/3879
3902: Fix heap and stack size for NUCLEO_F746ZG https://github.com/ARMmbed/mbed-os/pull/3902
3829: can_write(): return error code when no tx mailboxes are available https://github.com/ARMmbed/mbed-os/pull/3829

Who changed what in which revision?

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