Opencv 3.1 project on GR-PEACH board

Fork of gr-peach-opencv-project by the do

Committer:
thedo
Date:
Tue Jul 04 06:23:13 2017 +0000
Revision:
170:54ff26da7eb6
Parent:
166:3a9487d57a5c
project opencv 3.1 on GR PEACH board, no use SD card.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
thedo 166:3a9487d57a5c 1 /* mbed Microcontroller Library
thedo 166:3a9487d57a5c 2 * Copyright (c) 2006-2013 ARM Limited
thedo 166:3a9487d57a5c 3 *
thedo 166:3a9487d57a5c 4 * Licensed under the Apache License, Version 2.0 (the "License");
thedo 166:3a9487d57a5c 5 * you may not use this file except in compliance with the License.
thedo 166:3a9487d57a5c 6 * You may obtain a copy of the License at
thedo 166:3a9487d57a5c 7 *
thedo 166:3a9487d57a5c 8 * http://www.apache.org/licenses/LICENSE-2.0
thedo 166:3a9487d57a5c 9 *
thedo 166:3a9487d57a5c 10 * Unless required by applicable law or agreed to in writing, software
thedo 166:3a9487d57a5c 11 * distributed under the License is distributed on an "AS IS" BASIS,
thedo 166:3a9487d57a5c 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
thedo 166:3a9487d57a5c 13 * See the License for the specific language governing permissions and
thedo 166:3a9487d57a5c 14 * limitations under the License.
thedo 166:3a9487d57a5c 15 */
thedo 166:3a9487d57a5c 16 #ifndef MBED_LOCALFILESYSTEM_H
thedo 166:3a9487d57a5c 17 #define MBED_LOCALFILESYSTEM_H
thedo 166:3a9487d57a5c 18
thedo 166:3a9487d57a5c 19 #include "platform/platform.h"
thedo 166:3a9487d57a5c 20
thedo 166:3a9487d57a5c 21 #if DEVICE_LOCALFILESYSTEM
thedo 166:3a9487d57a5c 22
thedo 166:3a9487d57a5c 23 #include "platform/FileSystemLike.h"
thedo 166:3a9487d57a5c 24 #include "platform/PlatformMutex.h"
thedo 166:3a9487d57a5c 25
thedo 166:3a9487d57a5c 26 namespace mbed {
thedo 166:3a9487d57a5c 27 /** \addtogroup platform */
thedo 166:3a9487d57a5c 28 /** @{*/
thedo 166:3a9487d57a5c 29
thedo 166:3a9487d57a5c 30 FILEHANDLE local_file_open(const char* name, int flags);
thedo 166:3a9487d57a5c 31 /** @}*/
thedo 166:3a9487d57a5c 32
thedo 166:3a9487d57a5c 33 /**
thedo 166:3a9487d57a5c 34 * @class LocalFileHandle
thedo 166:3a9487d57a5c 35 * @ingroup platform
thedo 166:3a9487d57a5c 36 */
thedo 166:3a9487d57a5c 37 class LocalFileHandle : public FileHandle {
thedo 166:3a9487d57a5c 38
thedo 166:3a9487d57a5c 39 public:
thedo 166:3a9487d57a5c 40 LocalFileHandle(FILEHANDLE fh);
thedo 166:3a9487d57a5c 41
thedo 166:3a9487d57a5c 42 virtual int close();
thedo 166:3a9487d57a5c 43
thedo 166:3a9487d57a5c 44 virtual ssize_t write(const void *buffer, size_t length);
thedo 166:3a9487d57a5c 45
thedo 166:3a9487d57a5c 46 virtual ssize_t read(void *buffer, size_t length);
thedo 166:3a9487d57a5c 47
thedo 166:3a9487d57a5c 48 virtual int isatty();
thedo 166:3a9487d57a5c 49
thedo 166:3a9487d57a5c 50 virtual off_t seek(off_t position, int whence);
thedo 166:3a9487d57a5c 51
thedo 166:3a9487d57a5c 52 virtual int sync();
thedo 166:3a9487d57a5c 53
thedo 166:3a9487d57a5c 54 virtual off_t size();
thedo 166:3a9487d57a5c 55
thedo 166:3a9487d57a5c 56 protected:
thedo 166:3a9487d57a5c 57 virtual void lock();
thedo 166:3a9487d57a5c 58 virtual void unlock();
thedo 166:3a9487d57a5c 59 FILEHANDLE _fh;
thedo 166:3a9487d57a5c 60 int pos;
thedo 166:3a9487d57a5c 61 PlatformMutex _mutex;
thedo 166:3a9487d57a5c 62 };
thedo 166:3a9487d57a5c 63
thedo 166:3a9487d57a5c 64 /** A filesystem for accessing the local mbed Microcontroller USB disk drive
thedo 166:3a9487d57a5c 65 *
thedo 166:3a9487d57a5c 66 * This allows programs to read and write files on the same disk drive that is used to program the
thedo 166:3a9487d57a5c 67 * mbed Microcontroller. Once created, the standard C file access functions are used to open,
thedo 166:3a9487d57a5c 68 * read and write files.
thedo 166:3a9487d57a5c 69 *
thedo 166:3a9487d57a5c 70 * @note Synchronization level: Thread safe
thedo 166:3a9487d57a5c 71 *
thedo 166:3a9487d57a5c 72 * Example:
thedo 166:3a9487d57a5c 73 * @code
thedo 166:3a9487d57a5c 74 * #include "mbed.h"
thedo 166:3a9487d57a5c 75 *
thedo 166:3a9487d57a5c 76 * LocalFileSystem local("local"); // Create the local filesystem under the name "local"
thedo 166:3a9487d57a5c 77 *
thedo 166:3a9487d57a5c 78 * int main() {
thedo 166:3a9487d57a5c 79 * FILE *fp = fopen("/local/out.txt", "w"); // Open "out.txt" on the local file system for writing
thedo 166:3a9487d57a5c 80 * fprintf(fp, "Hello World!");
thedo 166:3a9487d57a5c 81 * fclose(fp);
thedo 166:3a9487d57a5c 82 * remove("/local/out.txt"); // Removes the file "out.txt" from the local file system
thedo 166:3a9487d57a5c 83 *
thedo 166:3a9487d57a5c 84 * DIR *d = opendir("/local"); // Opens the root directory of the local file system
thedo 166:3a9487d57a5c 85 * struct dirent *p;
thedo 166:3a9487d57a5c 86 * while((p = readdir(d)) != NULL) { // Print the names of the files in the local file system
thedo 166:3a9487d57a5c 87 * printf("%s\n", p->d_name); // to stdout.
thedo 166:3a9487d57a5c 88 * }
thedo 166:3a9487d57a5c 89 * closedir(d);
thedo 166:3a9487d57a5c 90 * }
thedo 166:3a9487d57a5c 91 * @endcode
thedo 166:3a9487d57a5c 92 *
thedo 166:3a9487d57a5c 93 * @note
thedo 166:3a9487d57a5c 94 * If the microcontroller program makes an access to the local drive, it will be marked as "removed"
thedo 166:3a9487d57a5c 95 * on the Host computer. This means it is no longer accessible from the Host Computer.
thedo 166:3a9487d57a5c 96 *
thedo 166:3a9487d57a5c 97 * The drive will only re-appear when the microcontroller program exists. Note that if the program does
thedo 166:3a9487d57a5c 98 * not exit, you will need to hold down reset on the mbed Microcontroller to be able to see the drive again!
thedo 166:3a9487d57a5c 99 * @ingroup platform
thedo 166:3a9487d57a5c 100 */
thedo 166:3a9487d57a5c 101 class LocalFileSystem : public FileSystemLike {
thedo 166:3a9487d57a5c 102 // No modifiable state
thedo 166:3a9487d57a5c 103
thedo 166:3a9487d57a5c 104 public:
thedo 166:3a9487d57a5c 105 LocalFileSystem(const char* n) : FileSystemLike(n) {
thedo 166:3a9487d57a5c 106
thedo 166:3a9487d57a5c 107 }
thedo 166:3a9487d57a5c 108
thedo 166:3a9487d57a5c 109 virtual int open(FileHandle **file, const char *path, int flags);
thedo 166:3a9487d57a5c 110 virtual int open(DirHandle **dir, const char *name);
thedo 166:3a9487d57a5c 111 virtual int remove(const char *filename);
thedo 166:3a9487d57a5c 112 };
thedo 166:3a9487d57a5c 113
thedo 166:3a9487d57a5c 114 } // namespace mbed
thedo 166:3a9487d57a5c 115
thedo 166:3a9487d57a5c 116 #endif
thedo 166:3a9487d57a5c 117
thedo 166:3a9487d57a5c 118 #endif
thedo 166:3a9487d57a5c 119
thedo 166:3a9487d57a5c 120