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