mbed library sources. Supersedes mbed-src.

Dependents:   SPIne CH_Communicatuin_Test CH_Communicatuin_Test2 MCP_SPIne ... more

Fork of mbed-dev-f303 by Ben Katz

Committer:
<>
Date:
Tue Mar 14 16:40:56 2017 +0000
Revision:
160:d5399cc887bb
Child:
161:2cc1468da177
This updates the lib to the mbed lib v138

Who changed what in which revision?

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