Includes library modifications to allow access to AIN_4 (AIN_0 / 5)

Committer:
bryantaylor
Date:
Tue Sep 20 21:26:12 2016 +0000
Revision:
0:eafc3fd41f75
hackathon

Who changed what in which revision?

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