fix nrf51822 i2c & spi conflict
Dependencies: BLE_API eMPL_MPU6050 nRF51822
Fork of Seeed_Tiny_BLE_Flash by
mbed-src/api/DirHandle.h@5:b8c02645e6af, 2015-11-17 (annotated)
- Committer:
- yihui
- Date:
- Tue Nov 17 07:48:56 2015 +0000
- Revision:
- 5:b8c02645e6af
fix i2c & spi conflict
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yihui | 5:b8c02645e6af | 1 | /* mbed Microcontroller Library |
yihui | 5:b8c02645e6af | 2 | * Copyright (c) 2006-2013 ARM Limited |
yihui | 5:b8c02645e6af | 3 | * |
yihui | 5:b8c02645e6af | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
yihui | 5:b8c02645e6af | 5 | * you may not use this file except in compliance with the License. |
yihui | 5:b8c02645e6af | 6 | * You may obtain a copy of the License at |
yihui | 5:b8c02645e6af | 7 | * |
yihui | 5:b8c02645e6af | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
yihui | 5:b8c02645e6af | 9 | * |
yihui | 5:b8c02645e6af | 10 | * Unless required by applicable law or agreed to in writing, software |
yihui | 5:b8c02645e6af | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
yihui | 5:b8c02645e6af | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
yihui | 5:b8c02645e6af | 13 | * See the License for the specific language governing permissions and |
yihui | 5:b8c02645e6af | 14 | * limitations under the License. |
yihui | 5:b8c02645e6af | 15 | */ |
yihui | 5:b8c02645e6af | 16 | #ifndef MBED_DIRHANDLE_H |
yihui | 5:b8c02645e6af | 17 | #define MBED_DIRHANDLE_H |
yihui | 5:b8c02645e6af | 18 | |
yihui | 5:b8c02645e6af | 19 | #if defined(__ARMCC_VERSION) || defined(__ICCARM__) |
yihui | 5:b8c02645e6af | 20 | # define NAME_MAX 255 |
yihui | 5:b8c02645e6af | 21 | typedef int mode_t; |
yihui | 5:b8c02645e6af | 22 | |
yihui | 5:b8c02645e6af | 23 | #else |
yihui | 5:b8c02645e6af | 24 | # include <sys/syslimits.h> |
yihui | 5:b8c02645e6af | 25 | #endif |
yihui | 5:b8c02645e6af | 26 | |
yihui | 5:b8c02645e6af | 27 | #include "FileHandle.h" |
yihui | 5:b8c02645e6af | 28 | |
yihui | 5:b8c02645e6af | 29 | struct dirent { |
yihui | 5:b8c02645e6af | 30 | char d_name[NAME_MAX+1]; |
yihui | 5:b8c02645e6af | 31 | }; |
yihui | 5:b8c02645e6af | 32 | |
yihui | 5:b8c02645e6af | 33 | namespace mbed { |
yihui | 5:b8c02645e6af | 34 | |
yihui | 5:b8c02645e6af | 35 | /** Represents a directory stream. Objects of this type are returned |
yihui | 5:b8c02645e6af | 36 | * by a FileSystemLike's opendir method. Implementations must define |
yihui | 5:b8c02645e6af | 37 | * at least closedir, readdir and rewinddir. |
yihui | 5:b8c02645e6af | 38 | * |
yihui | 5:b8c02645e6af | 39 | * If a FileSystemLike class defines the opendir method, then the |
yihui | 5:b8c02645e6af | 40 | * directories of an object of that type can be accessed by |
yihui | 5:b8c02645e6af | 41 | * DIR *d = opendir("/example/directory") (or opendir("/example") |
yihui | 5:b8c02645e6af | 42 | * to open the root of the filesystem), and then using readdir(d) etc. |
yihui | 5:b8c02645e6af | 43 | * |
yihui | 5:b8c02645e6af | 44 | * The root directory is considered to contain all FileLike and |
yihui | 5:b8c02645e6af | 45 | * FileSystemLike objects, so the DIR* returned by opendir("/") will |
yihui | 5:b8c02645e6af | 46 | * reflect this. |
yihui | 5:b8c02645e6af | 47 | */ |
yihui | 5:b8c02645e6af | 48 | class DirHandle { |
yihui | 5:b8c02645e6af | 49 | |
yihui | 5:b8c02645e6af | 50 | public: |
yihui | 5:b8c02645e6af | 51 | /** Closes the directory. |
yihui | 5:b8c02645e6af | 52 | * |
yihui | 5:b8c02645e6af | 53 | * @returns |
yihui | 5:b8c02645e6af | 54 | * 0 on success, |
yihui | 5:b8c02645e6af | 55 | * -1 on error. |
yihui | 5:b8c02645e6af | 56 | */ |
yihui | 5:b8c02645e6af | 57 | virtual int closedir()=0; |
yihui | 5:b8c02645e6af | 58 | |
yihui | 5:b8c02645e6af | 59 | /** Return the directory entry at the current position, and |
yihui | 5:b8c02645e6af | 60 | * advances the position to the next entry. |
yihui | 5:b8c02645e6af | 61 | * |
yihui | 5:b8c02645e6af | 62 | * @returns |
yihui | 5:b8c02645e6af | 63 | * A pointer to a dirent structure representing the |
yihui | 5:b8c02645e6af | 64 | * directory entry at the current position, or NULL on reaching |
yihui | 5:b8c02645e6af | 65 | * end of directory or error. |
yihui | 5:b8c02645e6af | 66 | */ |
yihui | 5:b8c02645e6af | 67 | virtual struct dirent *readdir()=0; |
yihui | 5:b8c02645e6af | 68 | |
yihui | 5:b8c02645e6af | 69 | /** Resets the position to the beginning of the directory. |
yihui | 5:b8c02645e6af | 70 | */ |
yihui | 5:b8c02645e6af | 71 | virtual void rewinddir()=0; |
yihui | 5:b8c02645e6af | 72 | |
yihui | 5:b8c02645e6af | 73 | /** Returns the current position of the DirHandle. |
yihui | 5:b8c02645e6af | 74 | * |
yihui | 5:b8c02645e6af | 75 | * @returns |
yihui | 5:b8c02645e6af | 76 | * the current position, |
yihui | 5:b8c02645e6af | 77 | * -1 on error. |
yihui | 5:b8c02645e6af | 78 | */ |
yihui | 5:b8c02645e6af | 79 | virtual off_t telldir() { return -1; } |
yihui | 5:b8c02645e6af | 80 | |
yihui | 5:b8c02645e6af | 81 | /** Sets the position of the DirHandle. |
yihui | 5:b8c02645e6af | 82 | * |
yihui | 5:b8c02645e6af | 83 | * @param location The location to seek to. Must be a value returned by telldir. |
yihui | 5:b8c02645e6af | 84 | */ |
yihui | 5:b8c02645e6af | 85 | virtual void seekdir(off_t location) { } |
yihui | 5:b8c02645e6af | 86 | |
yihui | 5:b8c02645e6af | 87 | virtual ~DirHandle() {} |
yihui | 5:b8c02645e6af | 88 | }; |
yihui | 5:b8c02645e6af | 89 | |
yihui | 5:b8c02645e6af | 90 | } // namespace mbed |
yihui | 5:b8c02645e6af | 91 | |
yihui | 5:b8c02645e6af | 92 | typedef mbed::DirHandle DIR; |
yihui | 5:b8c02645e6af | 93 | |
yihui | 5:b8c02645e6af | 94 | extern "C" { |
yihui | 5:b8c02645e6af | 95 | DIR *opendir(const char*); |
yihui | 5:b8c02645e6af | 96 | struct dirent *readdir(DIR *); |
yihui | 5:b8c02645e6af | 97 | int closedir(DIR*); |
yihui | 5:b8c02645e6af | 98 | void rewinddir(DIR*); |
yihui | 5:b8c02645e6af | 99 | long telldir(DIR*); |
yihui | 5:b8c02645e6af | 100 | void seekdir(DIR*, long); |
yihui | 5:b8c02645e6af | 101 | int mkdir(const char *name, mode_t n); |
yihui | 5:b8c02645e6af | 102 | }; |
yihui | 5:b8c02645e6af | 103 | |
yihui | 5:b8c02645e6af | 104 | #endif /* MBED_DIRHANDLE_H */ |