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.
platform/mbed_retarget.h@138:093f2bd7b9eb, 2017-03-14 (annotated)
- Committer:
- <>
- Date:
- Tue Mar 14 16:20:51 2017 +0000
- Revision:
- 138:093f2bd7b9eb
- Child:
- 139:856d2700e60b
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?
User | Revision | Line number | New 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; |
<> | 138:093f2bd7b9eb | 53 | |
<> | 138:093f2bd7b9eb | 54 | extern "C" { |
<> | 138:093f2bd7b9eb | 55 | DIR *opendir(const char*); |
<> | 138:093f2bd7b9eb | 56 | struct dirent *readdir(DIR *); |
<> | 138:093f2bd7b9eb | 57 | int closedir(DIR*); |
<> | 138:093f2bd7b9eb | 58 | void rewinddir(DIR*); |
<> | 138:093f2bd7b9eb | 59 | long telldir(DIR*); |
<> | 138:093f2bd7b9eb | 60 | void seekdir(DIR*, long); |
<> | 138:093f2bd7b9eb | 61 | int mkdir(const char *name, mode_t n); |
<> | 138:093f2bd7b9eb | 62 | }; |
<> | 138:093f2bd7b9eb | 63 | #endif |
<> | 138:093f2bd7b9eb | 64 | |
<> | 138:093f2bd7b9eb | 65 | |
<> | 138:093f2bd7b9eb | 66 | #if defined(__ARMCC_VERSION) || defined(__ICCARM__) |
<> | 138:093f2bd7b9eb | 67 | /* The intent of this section is to unify the errno error values to match |
<> | 138:093f2bd7b9eb | 68 | * the POSIX definitions for the GCC_ARM, ARMCC and IAR compilers. This is |
<> | 138:093f2bd7b9eb | 69 | * necessary because the ARMCC/IAR errno.h, or sys/stat.h are missing some |
<> | 138:093f2bd7b9eb | 70 | * symbol definitions used by the POSIX filesystem API to return errno codes. |
<> | 138:093f2bd7b9eb | 71 | * Note also that ARMCC errno.h defines some symbol values differently from |
<> | 138:093f2bd7b9eb | 72 | * the GCC_ARM/IAR/standard POSIX definitions. The definitions guard against |
<> | 138:093f2bd7b9eb | 73 | * this and future changes by changing the symbol definition as shown below. */ |
<> | 138:093f2bd7b9eb | 74 | #ifdef ENOENT |
<> | 138:093f2bd7b9eb | 75 | #undef ENOENT |
<> | 138:093f2bd7b9eb | 76 | #endif |
<> | 138:093f2bd7b9eb | 77 | #define ENOENT 2 /* No such file or directory. */ |
<> | 138:093f2bd7b9eb | 78 | |
<> | 138:093f2bd7b9eb | 79 | #ifdef EIO |
<> | 138:093f2bd7b9eb | 80 | #undef EIO |
<> | 138:093f2bd7b9eb | 81 | #endif |
<> | 138:093f2bd7b9eb | 82 | #define EIO 5 /* I/O error */ |
<> | 138:093f2bd7b9eb | 83 | |
<> | 138:093f2bd7b9eb | 84 | #ifdef ENXIO |
<> | 138:093f2bd7b9eb | 85 | #undef ENXIO |
<> | 138:093f2bd7b9eb | 86 | #endif |
<> | 138:093f2bd7b9eb | 87 | #define ENXIO 6 /* No such device or address */ |
<> | 138:093f2bd7b9eb | 88 | |
<> | 138:093f2bd7b9eb | 89 | #ifdef ENOEXEC |
<> | 138:093f2bd7b9eb | 90 | #undef ENOEXEC |
<> | 138:093f2bd7b9eb | 91 | #endif |
<> | 138:093f2bd7b9eb | 92 | #define ENOEXEC 8 /* Exec format error */ |
<> | 138:093f2bd7b9eb | 93 | |
<> | 138:093f2bd7b9eb | 94 | #ifdef EBADF |
<> | 138:093f2bd7b9eb | 95 | #undef EBADF |
<> | 138:093f2bd7b9eb | 96 | #endif |
<> | 138:093f2bd7b9eb | 97 | #define EBADF 9 /* Bad file number */ |
<> | 138:093f2bd7b9eb | 98 | |
<> | 138:093f2bd7b9eb | 99 | #ifdef ENOMEM |
<> | 138:093f2bd7b9eb | 100 | #undef ENOMEM |
<> | 138:093f2bd7b9eb | 101 | #endif |
<> | 138:093f2bd7b9eb | 102 | #define ENOMEM 12 /* Not enough space */ |
<> | 138:093f2bd7b9eb | 103 | |
<> | 138:093f2bd7b9eb | 104 | #ifdef EACCES |
<> | 138:093f2bd7b9eb | 105 | #undef EACCES |
<> | 138:093f2bd7b9eb | 106 | #endif |
<> | 138:093f2bd7b9eb | 107 | #define EACCES 13 /* Permission denied */ |
<> | 138:093f2bd7b9eb | 108 | |
<> | 138:093f2bd7b9eb | 109 | #ifdef EFAULT |
<> | 138:093f2bd7b9eb | 110 | #undef EFAULT |
<> | 138:093f2bd7b9eb | 111 | #endif |
<> | 138:093f2bd7b9eb | 112 | #define EFAULT 14 /* Bad address */ |
<> | 138:093f2bd7b9eb | 113 | |
<> | 138:093f2bd7b9eb | 114 | #ifdef EEXIST |
<> | 138:093f2bd7b9eb | 115 | #undef EEXIST |
<> | 138:093f2bd7b9eb | 116 | #endif |
<> | 138:093f2bd7b9eb | 117 | #define EEXIST 17 /* File exists */ |
<> | 138:093f2bd7b9eb | 118 | |
<> | 138:093f2bd7b9eb | 119 | #ifdef EINVAL |
<> | 138:093f2bd7b9eb | 120 | #undef EINVAL |
<> | 138:093f2bd7b9eb | 121 | #endif |
<> | 138:093f2bd7b9eb | 122 | #define EINVAL 22 /* Invalid argument */ |
<> | 138:093f2bd7b9eb | 123 | |
<> | 138:093f2bd7b9eb | 124 | #ifdef ENFILE |
<> | 138:093f2bd7b9eb | 125 | #undef ENFILE |
<> | 138:093f2bd7b9eb | 126 | #endif |
<> | 138:093f2bd7b9eb | 127 | #define ENFILE 23 /* Too many open files in system */ |
<> | 138:093f2bd7b9eb | 128 | |
<> | 138:093f2bd7b9eb | 129 | #ifdef EMFILE |
<> | 138:093f2bd7b9eb | 130 | #undef EMFILE |
<> | 138:093f2bd7b9eb | 131 | #endif |
<> | 138:093f2bd7b9eb | 132 | #define EMFILE 24 /* File descriptor value too large */ |
<> | 138:093f2bd7b9eb | 133 | |
<> | 138:093f2bd7b9eb | 134 | #ifdef ENOSYS |
<> | 138:093f2bd7b9eb | 135 | #undef ENOSYS |
<> | 138:093f2bd7b9eb | 136 | #endif |
<> | 138:093f2bd7b9eb | 137 | #define ENOSYS 38 /* Function not implemented */ |
<> | 138:093f2bd7b9eb | 138 | |
<> | 138:093f2bd7b9eb | 139 | /* Missing stat.h defines. |
<> | 138:093f2bd7b9eb | 140 | * The following are sys/stat.h definitions not currently present in the ARMCC |
<> | 138:093f2bd7b9eb | 141 | * errno.h. Note, ARMCC errno.h defines some symbol values differing from |
<> | 138:093f2bd7b9eb | 142 | * GCC_ARM/IAR/standard POSIX definitions. Guard against this and future |
<> | 138:093f2bd7b9eb | 143 | * changes by changing the symbol definition for filesystem use. */ |
<> | 138:093f2bd7b9eb | 144 | #define _IFDIR 0040000 /* directory */ |
<> | 138:093f2bd7b9eb | 145 | #define _IFREG 0100000 /* regular */ |
<> | 138:093f2bd7b9eb | 146 | |
<> | 138:093f2bd7b9eb | 147 | #define S_IFDIR _IFDIR |
<> | 138:093f2bd7b9eb | 148 | #define S_IFREG _IFREG |
<> | 138:093f2bd7b9eb | 149 | |
<> | 138:093f2bd7b9eb | 150 | #define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR) |
<> | 138:093f2bd7b9eb | 151 | #define S_IRUSR 0000400 /* read permission, owner */ |
<> | 138:093f2bd7b9eb | 152 | #define S_IWUSR 0000200 /* write permission, owner */ |
<> | 138:093f2bd7b9eb | 153 | #define S_IXUSR 0000100/* execute/search permission, owner */ |
<> | 138:093f2bd7b9eb | 154 | #define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP) |
<> | 138:093f2bd7b9eb | 155 | #define S_IRGRP 0000040 /* read permission, group */ |
<> | 138:093f2bd7b9eb | 156 | #define S_IWGRP 0000020 /* write permission, grougroup */ |
<> | 138:093f2bd7b9eb | 157 | #define S_IXGRP 0000010/* execute/search permission, group */ |
<> | 138:093f2bd7b9eb | 158 | #define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH) |
<> | 138:093f2bd7b9eb | 159 | #define S_IROTH 0000004 /* read permission, other */ |
<> | 138:093f2bd7b9eb | 160 | #define S_IWOTH 0000002 /* write permission, other */ |
<> | 138:093f2bd7b9eb | 161 | #define S_IXOTH 0000001/* execute/search permission, other */ |
<> | 138:093f2bd7b9eb | 162 | |
<> | 138:093f2bd7b9eb | 163 | #endif /* defined(__ARMCC_VERSION) || defined(__ICCARM__) */ |
<> | 138:093f2bd7b9eb | 164 | |
<> | 138:093f2bd7b9eb | 165 | |
<> | 138:093f2bd7b9eb | 166 | /* The following are dirent.h definitions are declared here to garuntee |
<> | 138:093f2bd7b9eb | 167 | * consistency where structure may be different with different toolchains */ |
<> | 138:093f2bd7b9eb | 168 | struct dirent { |
<> | 138:093f2bd7b9eb | 169 | char d_name[NAME_MAX+1]; |
<> | 138:093f2bd7b9eb | 170 | uint8_t d_type; |
<> | 138:093f2bd7b9eb | 171 | }; |
<> | 138:093f2bd7b9eb | 172 | |
<> | 138:093f2bd7b9eb | 173 | enum { |
<> | 138:093f2bd7b9eb | 174 | DT_UNKNOWN, // The file type could not be determined. |
<> | 138:093f2bd7b9eb | 175 | DT_FIFO, // This is a named pipe (FIFO). |
<> | 138:093f2bd7b9eb | 176 | DT_CHR, // This is a character device. |
<> | 138:093f2bd7b9eb | 177 | DT_DIR, // This is a directory. |
<> | 138:093f2bd7b9eb | 178 | DT_BLK, // This is a block device. |
<> | 138:093f2bd7b9eb | 179 | DT_REG, // This is a regular file. |
<> | 138:093f2bd7b9eb | 180 | DT_LNK, // This is a symbolic link. |
<> | 138:093f2bd7b9eb | 181 | DT_SOCK, // This is a UNIX domain socket. |
<> | 138:093f2bd7b9eb | 182 | }; |
<> | 138:093f2bd7b9eb | 183 | |
<> | 138:093f2bd7b9eb | 184 | |
<> | 138:093f2bd7b9eb | 185 | #endif /* RETARGET_H */ |