Modification of Mbed-dev library for LQFP48 package microcontrollers: STM32F103C8 (STM32F103C8T6) and STM32F103CB (STM32F103CBT6) (Bluepill boards, Maple mini etc. )
Fork of mbed-STM32F103C8_org by
mbed_retarget.h
00001 /* 00002 * mbed Microcontroller Library 00003 * Copyright (c) 2006-2016 ARM Limited 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 * 00017 */ 00018 00019 #ifndef RETARGET_H 00020 #define RETARGET_H 00021 00022 #include <stdint.h> 00023 #include <stddef.h> 00024 00025 /* We can get the following standard types from sys/types for gcc, but we 00026 * need to define the types ourselves for the other compilers that normally 00027 * target embedded systems */ 00028 #if defined(__ARMCC_VERSION) || defined(__ICCARM__) 00029 typedef int ssize_t; ///< Signed size type, usually encodes negative errors 00030 typedef long off_t; ///< Offset in a data stream 00031 typedef int mode_t; ///< Mode for opening files 00032 00033 #define O_RDONLY 0 00034 #define O_WRONLY 1 00035 #define O_RDWR 2 00036 #define O_CREAT 0x0200 00037 #define O_TRUNC 0x0400 00038 #define O_APPEND 0x0008 00039 00040 #define NAME_MAX 255 ///< Maximum size of a name in a file path 00041 00042 #else 00043 #include <sys/fcntl.h> 00044 #include <sys/types.h> 00045 #include <sys/syslimits.h> 00046 #endif 00047 00048 00049 /* DIR declarations must also be here */ 00050 #if __cplusplus 00051 namespace mbed { class Dir; } 00052 typedef mbed::Dir DIR; 00053 00054 extern "C" { 00055 DIR *opendir(const char*); 00056 struct dirent *readdir(DIR *); 00057 int closedir(DIR*); 00058 void rewinddir(DIR*); 00059 long telldir(DIR*); 00060 void seekdir(DIR*, long); 00061 int mkdir(const char *name, mode_t n); 00062 }; 00063 #endif 00064 00065 00066 #if defined(__ARMCC_VERSION) || defined(__ICCARM__) 00067 /* The intent of this section is to unify the errno error values to match 00068 * the POSIX definitions for the GCC_ARM, ARMCC and IAR compilers. This is 00069 * necessary because the ARMCC/IAR errno.h, or sys/stat.h are missing some 00070 * symbol definitions used by the POSIX filesystem API to return errno codes. 00071 * Note also that ARMCC errno.h defines some symbol values differently from 00072 * the GCC_ARM/IAR/standard POSIX definitions. The definitions guard against 00073 * this and future changes by changing the symbol definition as shown below. */ 00074 #ifdef ENOENT 00075 #undef ENOENT 00076 #endif 00077 #define ENOENT 2 /* No such file or directory. */ 00078 00079 #ifdef EIO 00080 #undef EIO 00081 #endif 00082 #define EIO 5 /* I/O error */ 00083 00084 #ifdef ENXIO 00085 #undef ENXIO 00086 #endif 00087 #define ENXIO 6 /* No such device or address */ 00088 00089 #ifdef ENOEXEC 00090 #undef ENOEXEC 00091 #endif 00092 #define ENOEXEC 8 /* Exec format error */ 00093 00094 #ifdef EBADF 00095 #undef EBADF 00096 #endif 00097 #define EBADF 9 /* Bad file number */ 00098 00099 #ifdef ENOMEM 00100 #undef ENOMEM 00101 #endif 00102 #define ENOMEM 12 /* Not enough space */ 00103 00104 #ifdef EACCES 00105 #undef EACCES 00106 #endif 00107 #define EACCES 13 /* Permission denied */ 00108 00109 #ifdef EFAULT 00110 #undef EFAULT 00111 #endif 00112 #define EFAULT 14 /* Bad address */ 00113 00114 #ifdef EEXIST 00115 #undef EEXIST 00116 #endif 00117 #define EEXIST 17 /* File exists */ 00118 00119 #ifdef EINVAL 00120 #undef EINVAL 00121 #endif 00122 #define EINVAL 22 /* Invalid argument */ 00123 00124 #ifdef ENFILE 00125 #undef ENFILE 00126 #endif 00127 #define ENFILE 23 /* Too many open files in system */ 00128 00129 #ifdef EMFILE 00130 #undef EMFILE 00131 #endif 00132 #define EMFILE 24 /* File descriptor value too large */ 00133 00134 #ifdef ENOSYS 00135 #undef ENOSYS 00136 #endif 00137 #define ENOSYS 38 /* Function not implemented */ 00138 00139 /* Missing stat.h defines. 00140 * The following are sys/stat.h definitions not currently present in the ARMCC 00141 * errno.h. Note, ARMCC errno.h defines some symbol values differing from 00142 * GCC_ARM/IAR/standard POSIX definitions. Guard against this and future 00143 * changes by changing the symbol definition for filesystem use. */ 00144 #define _IFDIR 0040000 /* directory */ 00145 #define _IFREG 0100000 /* regular */ 00146 00147 #define S_IFDIR _IFDIR 00148 #define S_IFREG _IFREG 00149 00150 #define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR) 00151 #define S_IRUSR 0000400 /* read permission, owner */ 00152 #define S_IWUSR 0000200 /* write permission, owner */ 00153 #define S_IXUSR 0000100/* execute/search permission, owner */ 00154 #define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP) 00155 #define S_IRGRP 0000040 /* read permission, group */ 00156 #define S_IWGRP 0000020 /* write permission, grougroup */ 00157 #define S_IXGRP 0000010/* execute/search permission, group */ 00158 #define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH) 00159 #define S_IROTH 0000004 /* read permission, other */ 00160 #define S_IWOTH 0000002 /* write permission, other */ 00161 #define S_IXOTH 0000001/* execute/search permission, other */ 00162 00163 #endif /* defined(__ARMCC_VERSION) || defined(__ICCARM__) */ 00164 00165 00166 /* The following are dirent.h definitions are declared here to garuntee 00167 * consistency where structure may be different with different toolchains */ 00168 struct dirent { 00169 char d_name[NAME_MAX+1]; 00170 uint8_t d_type; 00171 }; 00172 00173 enum { 00174 DT_UNKNOWN, // The file type could not be determined. 00175 DT_FIFO, // This is a named pipe (FIFO). 00176 DT_CHR, // This is a character device. 00177 DT_DIR, // This is a directory. 00178 DT_BLK, // This is a block device. 00179 DT_REG, // This is a regular file. 00180 DT_LNK, // This is a symbolic link. 00181 DT_SOCK, // This is a UNIX domain socket. 00182 }; 00183 00184 00185 #endif /* RETARGET_H */
Generated on Tue Jul 12 2022 16:30:32 by 1.7.2