Final version.

Dependencies:   F746_GUI F746_SAI_IO UIT_FFT_Real

Fork of F746_Spectrogram by 不韋 呂

Committer:
MikamiUitOpen
Date:
Sun Oct 02 10:51:10 2016 +0000
Revision:
4:c1beacfc42c7
5

Who changed what in which revision?

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