Audio singal input and output example for DISCO-F746. Input: MEMS mic, Output: CN10 OUT, Acoustic effect: echo and frequency shift. DISCO-F746 によるオーディオ信号入出力.入力:MEMS マイク,出力:CN10 OUT,音響効果:エコー,周波数変換.

Dependencies:   F746_GUI F746_SAI_IO

Committer:
MikamiUitOpen
Date:
Mon Apr 10 13:44:13 2017 +0000
Revision:
10:56f2f01df983
Parent:
6:38f7dce055d0
11

Who changed what in which revision?

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