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:
Wed Apr 12 16:07:08 2017 +0100
Revision:
140:97feb9bacc10
Parent:
139:856d2700e60b
Child:
145:64910690c574
Release 140 of the mbed library

Ports for Upcoming Targets

3841: Add nRf52840 target https://github.com/ARMmbed/mbed-os/pull/3841
3992: Introducing UBLOX_C030 platform. https://github.com/ARMmbed/mbed-os/pull/3992

Fixes and Changes

3951: [NUCLEO_F303ZE] Correct ARDUINO pin https://github.com/ARMmbed/mbed-os/pull/3951
4021: Fixing a macro to detect when RTOS was in use for the NRF52840_DK https://github.com/ARMmbed/mbed-os/pull/4021
3979: KW24D: Add missing SPI defines and Arduino connector definitions https://github.com/ARMmbed/mbed-os/pull/3979
3990: UBLOX_C027: construct a ticker-based wait, rather than calling wait_ms(), in the https://github.com/ARMmbed/mbed-os/pull/3990
4003: Fixed OBOE in async serial tx for NRF52 target, fixes #4002 https://github.com/ARMmbed/mbed-os/pull/4003
4012: STM32: Correct I2C master error handling https://github.com/ARMmbed/mbed-os/pull/4012
4020: NUCLEO_L011K4 remove unsupported tool chain files https://github.com/ARMmbed/mbed-os/pull/4020
4065: K66F: Move bss section to m_data_2 Section https://github.com/ARMmbed/mbed-os/pull/4065
4014: Issue 3763: Reduce heap allocation in the GCC linker file https://github.com/ARMmbed/mbed-os/pull/4014
4030: [STM32L0] reduce IAR heap and stack size for small targets https://github.com/ARMmbed/mbed-os/pull/4030
4109: NUCLEO_L476RG : minor serial pin update https://github.com/ARMmbed/mbed-os/pull/4109
3982: Ticker - kl25z bugfix for handling events in the past https://github.com/ARMmbed/mbed-os/pull/3982

Who changed what in which revision?

UserRevisionLine numberNew contents of line
<> 138:093f2bd7b9eb 1 /*
<> 138:093f2bd7b9eb 2 * mbed Microcontroller Library
<> 138:093f2bd7b9eb 3 * Copyright (c) 2006-2016 ARM Limited
<> 138:093f2bd7b9eb 4 *
<> 138:093f2bd7b9eb 5 * Licensed under the Apache License, Version 2.0 (the "License");
<> 138:093f2bd7b9eb 6 * you may not use this file except in compliance with the License.
<> 138:093f2bd7b9eb 7 * You may obtain a copy of the License at
<> 138:093f2bd7b9eb 8 *
<> 138:093f2bd7b9eb 9 * http://www.apache.org/licenses/LICENSE-2.0
<> 138:093f2bd7b9eb 10 *
<> 138:093f2bd7b9eb 11 * Unless required by applicable law or agreed to in writing, software
<> 138:093f2bd7b9eb 12 * distributed under the License is distributed on an "AS IS" BASIS,
<> 138:093f2bd7b9eb 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<> 138:093f2bd7b9eb 14 * See the License for the specific language governing permissions and
<> 138:093f2bd7b9eb 15 * limitations under the License.
<> 138:093f2bd7b9eb 16 *
<> 138:093f2bd7b9eb 17 */
<> 138:093f2bd7b9eb 18
<> 138:093f2bd7b9eb 19 #ifndef RETARGET_H
<> 138:093f2bd7b9eb 20 #define RETARGET_H
<> 138:093f2bd7b9eb 21
<> 138:093f2bd7b9eb 22 #include <stdint.h>
<> 138:093f2bd7b9eb 23 #include <stddef.h>
<> 138:093f2bd7b9eb 24
<> 138:093f2bd7b9eb 25 /* We can get the following standard types from sys/types for gcc, but we
<> 138:093f2bd7b9eb 26 * need to define the types ourselves for the other compilers that normally
<> 138:093f2bd7b9eb 27 * target embedded systems */
<> 138:093f2bd7b9eb 28 #if defined(__ARMCC_VERSION) || defined(__ICCARM__)
<> 138:093f2bd7b9eb 29 typedef int ssize_t; ///< Signed size type, usually encodes negative errors
<> 138:093f2bd7b9eb 30 typedef long off_t; ///< Offset in a data stream
<> 138:093f2bd7b9eb 31 typedef int mode_t; ///< Mode for opening files
<> 138:093f2bd7b9eb 32
<> 138:093f2bd7b9eb 33 #define O_RDONLY 0
<> 138:093f2bd7b9eb 34 #define O_WRONLY 1
<> 138:093f2bd7b9eb 35 #define O_RDWR 2
<> 138:093f2bd7b9eb 36 #define O_CREAT 0x0200
<> 138:093f2bd7b9eb 37 #define O_TRUNC 0x0400
<> 138:093f2bd7b9eb 38 #define O_APPEND 0x0008
<> 138:093f2bd7b9eb 39
<> 138:093f2bd7b9eb 40 #define NAME_MAX 255 ///< Maximum size of a name in a file path
<> 138:093f2bd7b9eb 41
<> 138:093f2bd7b9eb 42 #else
<> 138:093f2bd7b9eb 43 #include <sys/fcntl.h>
<> 138:093f2bd7b9eb 44 #include <sys/types.h>
<> 138:093f2bd7b9eb 45 #include <sys/syslimits.h>
<> 138:093f2bd7b9eb 46 #endif
<> 138:093f2bd7b9eb 47
<> 138:093f2bd7b9eb 48
<> 138:093f2bd7b9eb 49 /* DIR declarations must also be here */
<> 138:093f2bd7b9eb 50 #if __cplusplus
<> 138:093f2bd7b9eb 51 namespace mbed { class Dir; }
<> 138:093f2bd7b9eb 52 typedef mbed::Dir DIR;
<> 139:856d2700e60b 53 #else
<> 139:856d2700e60b 54 typedef struct Dir DIR;
<> 139:856d2700e60b 55 #endif
<> 138:093f2bd7b9eb 56
<> 139:856d2700e60b 57 #if __cplusplus
<> 138:093f2bd7b9eb 58 extern "C" {
<> 139:856d2700e60b 59 #endif
<> 138:093f2bd7b9eb 60 DIR *opendir(const char*);
<> 138:093f2bd7b9eb 61 struct dirent *readdir(DIR *);
<> 138:093f2bd7b9eb 62 int closedir(DIR*);
<> 138:093f2bd7b9eb 63 void rewinddir(DIR*);
<> 138:093f2bd7b9eb 64 long telldir(DIR*);
<> 138:093f2bd7b9eb 65 void seekdir(DIR*, long);
<> 138:093f2bd7b9eb 66 int mkdir(const char *name, mode_t n);
<> 139:856d2700e60b 67 #if __cplusplus
<> 138:093f2bd7b9eb 68 };
<> 138:093f2bd7b9eb 69 #endif
<> 138:093f2bd7b9eb 70
<> 138:093f2bd7b9eb 71
<> 138:093f2bd7b9eb 72 #if defined(__ARMCC_VERSION) || defined(__ICCARM__)
<> 138:093f2bd7b9eb 73 /* The intent of this section is to unify the errno error values to match
<> 138:093f2bd7b9eb 74 * the POSIX definitions for the GCC_ARM, ARMCC and IAR compilers. This is
<> 138:093f2bd7b9eb 75 * necessary because the ARMCC/IAR errno.h, or sys/stat.h are missing some
<> 138:093f2bd7b9eb 76 * symbol definitions used by the POSIX filesystem API to return errno codes.
<> 138:093f2bd7b9eb 77 * Note also that ARMCC errno.h defines some symbol values differently from
<> 138:093f2bd7b9eb 78 * the GCC_ARM/IAR/standard POSIX definitions. The definitions guard against
<> 138:093f2bd7b9eb 79 * this and future changes by changing the symbol definition as shown below. */
<> 138:093f2bd7b9eb 80 #ifdef ENOENT
<> 138:093f2bd7b9eb 81 #undef ENOENT
<> 138:093f2bd7b9eb 82 #endif
<> 138:093f2bd7b9eb 83 #define ENOENT 2 /* No such file or directory. */
<> 138:093f2bd7b9eb 84
<> 138:093f2bd7b9eb 85 #ifdef EIO
<> 138:093f2bd7b9eb 86 #undef EIO
<> 138:093f2bd7b9eb 87 #endif
<> 138:093f2bd7b9eb 88 #define EIO 5 /* I/O error */
<> 138:093f2bd7b9eb 89
<> 138:093f2bd7b9eb 90 #ifdef ENXIO
<> 138:093f2bd7b9eb 91 #undef ENXIO
<> 138:093f2bd7b9eb 92 #endif
<> 138:093f2bd7b9eb 93 #define ENXIO 6 /* No such device or address */
<> 138:093f2bd7b9eb 94
<> 138:093f2bd7b9eb 95 #ifdef ENOEXEC
<> 138:093f2bd7b9eb 96 #undef ENOEXEC
<> 138:093f2bd7b9eb 97 #endif
<> 138:093f2bd7b9eb 98 #define ENOEXEC 8 /* Exec format error */
<> 138:093f2bd7b9eb 99
<> 138:093f2bd7b9eb 100 #ifdef EBADF
<> 138:093f2bd7b9eb 101 #undef EBADF
<> 138:093f2bd7b9eb 102 #endif
<> 138:093f2bd7b9eb 103 #define EBADF 9 /* Bad file number */
<> 138:093f2bd7b9eb 104
<> 138:093f2bd7b9eb 105 #ifdef ENOMEM
<> 138:093f2bd7b9eb 106 #undef ENOMEM
<> 138:093f2bd7b9eb 107 #endif
<> 138:093f2bd7b9eb 108 #define ENOMEM 12 /* Not enough space */
<> 138:093f2bd7b9eb 109
<> 138:093f2bd7b9eb 110 #ifdef EACCES
<> 138:093f2bd7b9eb 111 #undef EACCES
<> 138:093f2bd7b9eb 112 #endif
<> 138:093f2bd7b9eb 113 #define EACCES 13 /* Permission denied */
<> 138:093f2bd7b9eb 114
<> 138:093f2bd7b9eb 115 #ifdef EFAULT
<> 138:093f2bd7b9eb 116 #undef EFAULT
<> 138:093f2bd7b9eb 117 #endif
<> 138:093f2bd7b9eb 118 #define EFAULT 14 /* Bad address */
<> 138:093f2bd7b9eb 119
<> 138:093f2bd7b9eb 120 #ifdef EEXIST
<> 138:093f2bd7b9eb 121 #undef EEXIST
<> 138:093f2bd7b9eb 122 #endif
<> 138:093f2bd7b9eb 123 #define EEXIST 17 /* File exists */
<> 138:093f2bd7b9eb 124
<> 138:093f2bd7b9eb 125 #ifdef EINVAL
<> 138:093f2bd7b9eb 126 #undef EINVAL
<> 138:093f2bd7b9eb 127 #endif
<> 138:093f2bd7b9eb 128 #define EINVAL 22 /* Invalid argument */
<> 138:093f2bd7b9eb 129
<> 138:093f2bd7b9eb 130 #ifdef ENFILE
<> 138:093f2bd7b9eb 131 #undef ENFILE
<> 138:093f2bd7b9eb 132 #endif
<> 138:093f2bd7b9eb 133 #define ENFILE 23 /* Too many open files in system */
<> 138:093f2bd7b9eb 134
<> 138:093f2bd7b9eb 135 #ifdef EMFILE
<> 138:093f2bd7b9eb 136 #undef EMFILE
<> 138:093f2bd7b9eb 137 #endif
<> 138:093f2bd7b9eb 138 #define EMFILE 24 /* File descriptor value too large */
<> 138:093f2bd7b9eb 139
<> 138:093f2bd7b9eb 140 #ifdef ENOSYS
<> 138:093f2bd7b9eb 141 #undef ENOSYS
<> 138:093f2bd7b9eb 142 #endif
<> 138:093f2bd7b9eb 143 #define ENOSYS 38 /* Function not implemented */
<> 138:093f2bd7b9eb 144
<> 138:093f2bd7b9eb 145 /* Missing stat.h defines.
<> 138:093f2bd7b9eb 146 * The following are sys/stat.h definitions not currently present in the ARMCC
<> 138:093f2bd7b9eb 147 * errno.h. Note, ARMCC errno.h defines some symbol values differing from
<> 138:093f2bd7b9eb 148 * GCC_ARM/IAR/standard POSIX definitions. Guard against this and future
<> 138:093f2bd7b9eb 149 * changes by changing the symbol definition for filesystem use. */
<> 138:093f2bd7b9eb 150 #define _IFDIR 0040000 /* directory */
<> 138:093f2bd7b9eb 151 #define _IFREG 0100000 /* regular */
<> 138:093f2bd7b9eb 152
<> 138:093f2bd7b9eb 153 #define S_IFDIR _IFDIR
<> 138:093f2bd7b9eb 154 #define S_IFREG _IFREG
<> 138:093f2bd7b9eb 155
<> 138:093f2bd7b9eb 156 #define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
<> 138:093f2bd7b9eb 157 #define S_IRUSR 0000400 /* read permission, owner */
<> 138:093f2bd7b9eb 158 #define S_IWUSR 0000200 /* write permission, owner */
<> 138:093f2bd7b9eb 159 #define S_IXUSR 0000100/* execute/search permission, owner */
<> 138:093f2bd7b9eb 160 #define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
<> 138:093f2bd7b9eb 161 #define S_IRGRP 0000040 /* read permission, group */
<> 138:093f2bd7b9eb 162 #define S_IWGRP 0000020 /* write permission, grougroup */
<> 138:093f2bd7b9eb 163 #define S_IXGRP 0000010/* execute/search permission, group */
<> 138:093f2bd7b9eb 164 #define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
<> 138:093f2bd7b9eb 165 #define S_IROTH 0000004 /* read permission, other */
<> 138:093f2bd7b9eb 166 #define S_IWOTH 0000002 /* write permission, other */
<> 138:093f2bd7b9eb 167 #define S_IXOTH 0000001/* execute/search permission, other */
<> 138:093f2bd7b9eb 168
<> 138:093f2bd7b9eb 169 #endif /* defined(__ARMCC_VERSION) || defined(__ICCARM__) */
<> 138:093f2bd7b9eb 170
<> 138:093f2bd7b9eb 171
<> 138:093f2bd7b9eb 172 /* The following are dirent.h definitions are declared here to garuntee
<> 138:093f2bd7b9eb 173 * consistency where structure may be different with different toolchains */
<> 138:093f2bd7b9eb 174 struct dirent {
<> 138:093f2bd7b9eb 175 char d_name[NAME_MAX+1];
<> 138:093f2bd7b9eb 176 uint8_t d_type;
<> 138:093f2bd7b9eb 177 };
<> 138:093f2bd7b9eb 178
<> 138:093f2bd7b9eb 179 enum {
<> 138:093f2bd7b9eb 180 DT_UNKNOWN, // The file type could not be determined.
<> 138:093f2bd7b9eb 181 DT_FIFO, // This is a named pipe (FIFO).
<> 138:093f2bd7b9eb 182 DT_CHR, // This is a character device.
<> 138:093f2bd7b9eb 183 DT_DIR, // This is a directory.
<> 138:093f2bd7b9eb 184 DT_BLK, // This is a block device.
<> 138:093f2bd7b9eb 185 DT_REG, // This is a regular file.
<> 138:093f2bd7b9eb 186 DT_LNK, // This is a symbolic link.
<> 138:093f2bd7b9eb 187 DT_SOCK, // This is a UNIX domain socket.
<> 138:093f2bd7b9eb 188 };
<> 138:093f2bd7b9eb 189
<> 138:093f2bd7b9eb 190
<> 138:093f2bd7b9eb 191 #endif /* RETARGET_H */