Integrated program of 4 different kinds of application programs for processing sound signal. 4種類のサウンド信号処理を統合したプログラム.
Dependencies: F746_GUI F746_SAI_IO FrequencyResponseDrawer SD_PlayerSkeleton UIT_FFT_Real
mbed_src_STM32F7/common/Stream.cpp@2:fcba17e3d573, 2016-09-26 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Mon Sep 26 07:07:05 2016 +0000
- Revision:
- 2:fcba17e3d573
- Parent:
- mbed_src_STM/common/Stream.cpp@0:224dccbc4edd
3
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MikamiUitOpen | 0:224dccbc4edd | 1 | /* mbed Microcontroller Library |
MikamiUitOpen | 0:224dccbc4edd | 2 | * Copyright (c) 2006-2013 ARM Limited |
MikamiUitOpen | 0:224dccbc4edd | 3 | * |
MikamiUitOpen | 0:224dccbc4edd | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
MikamiUitOpen | 0:224dccbc4edd | 5 | * you may not use this file except in compliance with the License. |
MikamiUitOpen | 0:224dccbc4edd | 6 | * You may obtain a copy of the License at |
MikamiUitOpen | 0:224dccbc4edd | 7 | * |
MikamiUitOpen | 0:224dccbc4edd | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
MikamiUitOpen | 0:224dccbc4edd | 9 | * |
MikamiUitOpen | 0:224dccbc4edd | 10 | * Unless required by applicable law or agreed to in writing, software |
MikamiUitOpen | 0:224dccbc4edd | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
MikamiUitOpen | 0:224dccbc4edd | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
MikamiUitOpen | 0:224dccbc4edd | 13 | * See the License for the specific language governing permissions and |
MikamiUitOpen | 0:224dccbc4edd | 14 | * limitations under the License. |
MikamiUitOpen | 0:224dccbc4edd | 15 | */ |
MikamiUitOpen | 0:224dccbc4edd | 16 | #include "Stream.h" |
MikamiUitOpen | 0:224dccbc4edd | 17 | |
MikamiUitOpen | 0:224dccbc4edd | 18 | namespace mbed { |
MikamiUitOpen | 0:224dccbc4edd | 19 | |
MikamiUitOpen | 0:224dccbc4edd | 20 | Stream::Stream(const char *name) : FileLike(name), _file(NULL) { |
MikamiUitOpen | 0:224dccbc4edd | 21 | /* open ourselves */ |
MikamiUitOpen | 0:224dccbc4edd | 22 | char buf[12]; /* :0x12345678 + null byte */ |
MikamiUitOpen | 0:224dccbc4edd | 23 | std::sprintf(buf, ":%p", this); |
MikamiUitOpen | 0:224dccbc4edd | 24 | _file = std::fopen(buf, "w+"); |
MikamiUitOpen | 0:224dccbc4edd | 25 | mbed_set_unbuffered_stream(_file); |
MikamiUitOpen | 0:224dccbc4edd | 26 | } |
MikamiUitOpen | 0:224dccbc4edd | 27 | |
MikamiUitOpen | 0:224dccbc4edd | 28 | Stream::~Stream() { |
MikamiUitOpen | 0:224dccbc4edd | 29 | fclose(_file); |
MikamiUitOpen | 0:224dccbc4edd | 30 | } |
MikamiUitOpen | 0:224dccbc4edd | 31 | |
MikamiUitOpen | 0:224dccbc4edd | 32 | int Stream::putc(int c) { |
MikamiUitOpen | 0:224dccbc4edd | 33 | fflush(_file); |
MikamiUitOpen | 0:224dccbc4edd | 34 | return std::fputc(c, _file); |
MikamiUitOpen | 0:224dccbc4edd | 35 | } |
MikamiUitOpen | 0:224dccbc4edd | 36 | int Stream::puts(const char *s) { |
MikamiUitOpen | 0:224dccbc4edd | 37 | fflush(_file); |
MikamiUitOpen | 0:224dccbc4edd | 38 | return std::fputs(s, _file); |
MikamiUitOpen | 0:224dccbc4edd | 39 | } |
MikamiUitOpen | 0:224dccbc4edd | 40 | int Stream::getc() { |
MikamiUitOpen | 0:224dccbc4edd | 41 | fflush(_file); |
MikamiUitOpen | 0:224dccbc4edd | 42 | return mbed_getc(_file); |
MikamiUitOpen | 0:224dccbc4edd | 43 | } |
MikamiUitOpen | 0:224dccbc4edd | 44 | char* Stream::gets(char *s, int size) { |
MikamiUitOpen | 0:224dccbc4edd | 45 | fflush(_file); |
MikamiUitOpen | 0:224dccbc4edd | 46 | return mbed_gets(s,size,_file); |
MikamiUitOpen | 0:224dccbc4edd | 47 | } |
MikamiUitOpen | 0:224dccbc4edd | 48 | |
MikamiUitOpen | 0:224dccbc4edd | 49 | int Stream::close() { |
MikamiUitOpen | 0:224dccbc4edd | 50 | return 0; |
MikamiUitOpen | 0:224dccbc4edd | 51 | } |
MikamiUitOpen | 0:224dccbc4edd | 52 | |
MikamiUitOpen | 0:224dccbc4edd | 53 | ssize_t Stream::write(const void* buffer, size_t length) { |
MikamiUitOpen | 0:224dccbc4edd | 54 | const char* ptr = (const char*)buffer; |
MikamiUitOpen | 0:224dccbc4edd | 55 | const char* end = ptr + length; |
MikamiUitOpen | 0:224dccbc4edd | 56 | while (ptr != end) { |
MikamiUitOpen | 0:224dccbc4edd | 57 | if (_putc(*ptr++) == EOF) { |
MikamiUitOpen | 0:224dccbc4edd | 58 | break; |
MikamiUitOpen | 0:224dccbc4edd | 59 | } |
MikamiUitOpen | 0:224dccbc4edd | 60 | } |
MikamiUitOpen | 0:224dccbc4edd | 61 | return ptr - (const char*)buffer; |
MikamiUitOpen | 0:224dccbc4edd | 62 | } |
MikamiUitOpen | 0:224dccbc4edd | 63 | |
MikamiUitOpen | 0:224dccbc4edd | 64 | ssize_t Stream::read(void* buffer, size_t length) { |
MikamiUitOpen | 0:224dccbc4edd | 65 | char* ptr = (char*)buffer; |
MikamiUitOpen | 0:224dccbc4edd | 66 | char* end = ptr + length; |
MikamiUitOpen | 0:224dccbc4edd | 67 | while (ptr != end) { |
MikamiUitOpen | 0:224dccbc4edd | 68 | int c = _getc(); |
MikamiUitOpen | 0:224dccbc4edd | 69 | if (c==EOF) break; |
MikamiUitOpen | 0:224dccbc4edd | 70 | *ptr++ = c; |
MikamiUitOpen | 0:224dccbc4edd | 71 | } |
MikamiUitOpen | 0:224dccbc4edd | 72 | return ptr - (const char*)buffer; |
MikamiUitOpen | 0:224dccbc4edd | 73 | } |
MikamiUitOpen | 0:224dccbc4edd | 74 | |
MikamiUitOpen | 0:224dccbc4edd | 75 | off_t Stream::lseek(off_t offset, int whence) { |
MikamiUitOpen | 0:224dccbc4edd | 76 | return 0; |
MikamiUitOpen | 0:224dccbc4edd | 77 | } |
MikamiUitOpen | 0:224dccbc4edd | 78 | |
MikamiUitOpen | 0:224dccbc4edd | 79 | int Stream::isatty() { |
MikamiUitOpen | 0:224dccbc4edd | 80 | return 0; |
MikamiUitOpen | 0:224dccbc4edd | 81 | } |
MikamiUitOpen | 0:224dccbc4edd | 82 | |
MikamiUitOpen | 0:224dccbc4edd | 83 | int Stream::fsync() { |
MikamiUitOpen | 0:224dccbc4edd | 84 | return 0; |
MikamiUitOpen | 0:224dccbc4edd | 85 | } |
MikamiUitOpen | 0:224dccbc4edd | 86 | |
MikamiUitOpen | 0:224dccbc4edd | 87 | off_t Stream::flen() { |
MikamiUitOpen | 0:224dccbc4edd | 88 | return 0; |
MikamiUitOpen | 0:224dccbc4edd | 89 | } |
MikamiUitOpen | 0:224dccbc4edd | 90 | |
MikamiUitOpen | 0:224dccbc4edd | 91 | int Stream::printf(const char* format, ...) { |
MikamiUitOpen | 0:224dccbc4edd | 92 | std::va_list arg; |
MikamiUitOpen | 0:224dccbc4edd | 93 | va_start(arg, format); |
MikamiUitOpen | 0:224dccbc4edd | 94 | fflush(_file); |
MikamiUitOpen | 0:224dccbc4edd | 95 | int r = vfprintf(_file, format, arg); |
MikamiUitOpen | 0:224dccbc4edd | 96 | va_end(arg); |
MikamiUitOpen | 0:224dccbc4edd | 97 | return r; |
MikamiUitOpen | 0:224dccbc4edd | 98 | } |
MikamiUitOpen | 0:224dccbc4edd | 99 | |
MikamiUitOpen | 0:224dccbc4edd | 100 | int Stream::scanf(const char* format, ...) { |
MikamiUitOpen | 0:224dccbc4edd | 101 | std::va_list arg; |
MikamiUitOpen | 0:224dccbc4edd | 102 | va_start(arg, format); |
MikamiUitOpen | 0:224dccbc4edd | 103 | fflush(_file); |
MikamiUitOpen | 0:224dccbc4edd | 104 | int r = vfscanf(_file, format, arg); |
MikamiUitOpen | 0:224dccbc4edd | 105 | va_end(arg); |
MikamiUitOpen | 0:224dccbc4edd | 106 | return r; |
MikamiUitOpen | 0:224dccbc4edd | 107 | } |
MikamiUitOpen | 0:224dccbc4edd | 108 | |
MikamiUitOpen | 0:224dccbc4edd | 109 | int Stream::vprintf(const char* format, std::va_list args) { |
MikamiUitOpen | 0:224dccbc4edd | 110 | fflush(_file); |
MikamiUitOpen | 0:224dccbc4edd | 111 | int r = vfprintf(_file, format, args); |
MikamiUitOpen | 0:224dccbc4edd | 112 | return r; |
MikamiUitOpen | 0:224dccbc4edd | 113 | } |
MikamiUitOpen | 0:224dccbc4edd | 114 | |
MikamiUitOpen | 0:224dccbc4edd | 115 | int Stream::vscanf(const char* format, std::va_list args) { |
MikamiUitOpen | 0:224dccbc4edd | 116 | fflush(_file); |
MikamiUitOpen | 0:224dccbc4edd | 117 | int r = vfscanf(_file, format, args); |
MikamiUitOpen | 0:224dccbc4edd | 118 | return r; |
MikamiUitOpen | 0:224dccbc4edd | 119 | } |
MikamiUitOpen | 0:224dccbc4edd | 120 | |
MikamiUitOpen | 0:224dccbc4edd | 121 | } // namespace mbed |