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

Committer:
MikamiUitOpen
Date:
Mon Aug 15 07:18:07 2016 +0000
Revision:
0:224dccbc4edd
1

Who changed what in which revision?

UserRevisionLine numberNew 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 "cmsis.h"
MikamiUitOpen 0:224dccbc4edd 17 #include "semihost_api.h"
MikamiUitOpen 0:224dccbc4edd 18
MikamiUitOpen 0:224dccbc4edd 19 #include <stdint.h>
MikamiUitOpen 0:224dccbc4edd 20 #include <string.h>
MikamiUitOpen 0:224dccbc4edd 21
MikamiUitOpen 0:224dccbc4edd 22 #if DEVICE_SEMIHOST
MikamiUitOpen 0:224dccbc4edd 23
MikamiUitOpen 0:224dccbc4edd 24 // ARM Semihosting Commands
MikamiUitOpen 0:224dccbc4edd 25 #define SYS_OPEN (0x1)
MikamiUitOpen 0:224dccbc4edd 26 #define SYS_CLOSE (0x2)
MikamiUitOpen 0:224dccbc4edd 27 #define SYS_WRITE (0x5)
MikamiUitOpen 0:224dccbc4edd 28 #define SYS_READ (0x6)
MikamiUitOpen 0:224dccbc4edd 29 #define SYS_ISTTY (0x9)
MikamiUitOpen 0:224dccbc4edd 30 #define SYS_SEEK (0xa)
MikamiUitOpen 0:224dccbc4edd 31 #define SYS_ENSURE (0xb)
MikamiUitOpen 0:224dccbc4edd 32 #define SYS_FLEN (0xc)
MikamiUitOpen 0:224dccbc4edd 33 #define SYS_REMOVE (0xe)
MikamiUitOpen 0:224dccbc4edd 34 #define SYS_RENAME (0xf)
MikamiUitOpen 0:224dccbc4edd 35 #define SYS_EXIT (0x18)
MikamiUitOpen 0:224dccbc4edd 36
MikamiUitOpen 0:224dccbc4edd 37 // mbed Semihosting Commands
MikamiUitOpen 0:224dccbc4edd 38 #define RESERVED_FOR_USER_APPLICATIONS (0x100) // 0x100 - 0x1ff
MikamiUitOpen 0:224dccbc4edd 39 #define USR_XFFIND (RESERVED_FOR_USER_APPLICATIONS + 0)
MikamiUitOpen 0:224dccbc4edd 40 #define USR_UID (RESERVED_FOR_USER_APPLICATIONS + 1)
MikamiUitOpen 0:224dccbc4edd 41 #define USR_RESET (RESERVED_FOR_USER_APPLICATIONS + 2)
MikamiUitOpen 0:224dccbc4edd 42 #define USR_VBUS (RESERVED_FOR_USER_APPLICATIONS + 3)
MikamiUitOpen 0:224dccbc4edd 43 #define USR_POWERDOWN (RESERVED_FOR_USER_APPLICATIONS + 4)
MikamiUitOpen 0:224dccbc4edd 44 #define USR_DISABLEDEBUG (RESERVED_FOR_USER_APPLICATIONS + 5)
MikamiUitOpen 0:224dccbc4edd 45
MikamiUitOpen 0:224dccbc4edd 46 #if DEVICE_LOCALFILESYSTEM
MikamiUitOpen 0:224dccbc4edd 47 FILEHANDLE semihost_open(const char* name, int openmode) {
MikamiUitOpen 0:224dccbc4edd 48 uint32_t args[3];
MikamiUitOpen 0:224dccbc4edd 49 args[0] = (uint32_t)name;
MikamiUitOpen 0:224dccbc4edd 50 args[1] = (uint32_t)openmode;
MikamiUitOpen 0:224dccbc4edd 51 args[2] = (uint32_t)strlen(name);
MikamiUitOpen 0:224dccbc4edd 52 return __semihost(SYS_OPEN, args);
MikamiUitOpen 0:224dccbc4edd 53 }
MikamiUitOpen 0:224dccbc4edd 54
MikamiUitOpen 0:224dccbc4edd 55 int semihost_close(FILEHANDLE fh) {
MikamiUitOpen 0:224dccbc4edd 56 return __semihost(SYS_CLOSE, &fh);
MikamiUitOpen 0:224dccbc4edd 57 }
MikamiUitOpen 0:224dccbc4edd 58
MikamiUitOpen 0:224dccbc4edd 59 int semihost_write(FILEHANDLE fh, const unsigned char* buffer, unsigned int length, int mode) {
MikamiUitOpen 0:224dccbc4edd 60 if (length == 0) return 0;
MikamiUitOpen 0:224dccbc4edd 61
MikamiUitOpen 0:224dccbc4edd 62 uint32_t args[3];
MikamiUitOpen 0:224dccbc4edd 63 args[0] = (uint32_t)fh;
MikamiUitOpen 0:224dccbc4edd 64 args[1] = (uint32_t)buffer;
MikamiUitOpen 0:224dccbc4edd 65 args[2] = (uint32_t)length;
MikamiUitOpen 0:224dccbc4edd 66 return __semihost(SYS_WRITE, args);
MikamiUitOpen 0:224dccbc4edd 67 }
MikamiUitOpen 0:224dccbc4edd 68
MikamiUitOpen 0:224dccbc4edd 69 int semihost_read(FILEHANDLE fh, unsigned char* buffer, unsigned int length, int mode) {
MikamiUitOpen 0:224dccbc4edd 70 uint32_t args[3];
MikamiUitOpen 0:224dccbc4edd 71 args[0] = (uint32_t)fh;
MikamiUitOpen 0:224dccbc4edd 72 args[1] = (uint32_t)buffer;
MikamiUitOpen 0:224dccbc4edd 73 args[2] = (uint32_t)length;
MikamiUitOpen 0:224dccbc4edd 74 return __semihost(SYS_READ, args);
MikamiUitOpen 0:224dccbc4edd 75 }
MikamiUitOpen 0:224dccbc4edd 76
MikamiUitOpen 0:224dccbc4edd 77 int semihost_istty(FILEHANDLE fh) {
MikamiUitOpen 0:224dccbc4edd 78 return __semihost(SYS_ISTTY, &fh);
MikamiUitOpen 0:224dccbc4edd 79 }
MikamiUitOpen 0:224dccbc4edd 80
MikamiUitOpen 0:224dccbc4edd 81 int semihost_seek(FILEHANDLE fh, long position) {
MikamiUitOpen 0:224dccbc4edd 82 uint32_t args[2];
MikamiUitOpen 0:224dccbc4edd 83 args[0] = (uint32_t)fh;
MikamiUitOpen 0:224dccbc4edd 84 args[1] = (uint32_t)position;
MikamiUitOpen 0:224dccbc4edd 85 return __semihost(SYS_SEEK, args);
MikamiUitOpen 0:224dccbc4edd 86 }
MikamiUitOpen 0:224dccbc4edd 87
MikamiUitOpen 0:224dccbc4edd 88 int semihost_ensure(FILEHANDLE fh) {
MikamiUitOpen 0:224dccbc4edd 89 return __semihost(SYS_ENSURE, &fh);
MikamiUitOpen 0:224dccbc4edd 90 }
MikamiUitOpen 0:224dccbc4edd 91
MikamiUitOpen 0:224dccbc4edd 92 long semihost_flen(FILEHANDLE fh) {
MikamiUitOpen 0:224dccbc4edd 93 return __semihost(SYS_FLEN, &fh);
MikamiUitOpen 0:224dccbc4edd 94 }
MikamiUitOpen 0:224dccbc4edd 95
MikamiUitOpen 0:224dccbc4edd 96 int semihost_remove(const char *name) {
MikamiUitOpen 0:224dccbc4edd 97 uint32_t args[2];
MikamiUitOpen 0:224dccbc4edd 98 args[0] = (uint32_t)name;
MikamiUitOpen 0:224dccbc4edd 99 args[1] = (uint32_t)strlen(name);
MikamiUitOpen 0:224dccbc4edd 100 return __semihost(SYS_REMOVE, args);
MikamiUitOpen 0:224dccbc4edd 101 }
MikamiUitOpen 0:224dccbc4edd 102
MikamiUitOpen 0:224dccbc4edd 103 int semihost_rename(const char *old_name, const char *new_name) {
MikamiUitOpen 0:224dccbc4edd 104 uint32_t args[4];
MikamiUitOpen 0:224dccbc4edd 105 args[0] = (uint32_t)old_name;
MikamiUitOpen 0:224dccbc4edd 106 args[1] = (uint32_t)strlen(old_name);
MikamiUitOpen 0:224dccbc4edd 107 args[0] = (uint32_t)new_name;
MikamiUitOpen 0:224dccbc4edd 108 args[1] = (uint32_t)strlen(new_name);
MikamiUitOpen 0:224dccbc4edd 109 return __semihost(SYS_RENAME, args);
MikamiUitOpen 0:224dccbc4edd 110 }
MikamiUitOpen 0:224dccbc4edd 111 #endif
MikamiUitOpen 0:224dccbc4edd 112
MikamiUitOpen 0:224dccbc4edd 113 int semihost_exit(void) {
MikamiUitOpen 0:224dccbc4edd 114 uint32_t args[4];
MikamiUitOpen 0:224dccbc4edd 115 return __semihost(SYS_EXIT, args);
MikamiUitOpen 0:224dccbc4edd 116 }
MikamiUitOpen 0:224dccbc4edd 117
MikamiUitOpen 0:224dccbc4edd 118 int semihost_uid(char *uid) {
MikamiUitOpen 0:224dccbc4edd 119 uint32_t args[2];
MikamiUitOpen 0:224dccbc4edd 120 args[0] = (uint32_t)uid;
MikamiUitOpen 0:224dccbc4edd 121 args[1] = DEVICE_ID_LENGTH + 1;
MikamiUitOpen 0:224dccbc4edd 122 return __semihost(USR_UID, &args);
MikamiUitOpen 0:224dccbc4edd 123 }
MikamiUitOpen 0:224dccbc4edd 124
MikamiUitOpen 0:224dccbc4edd 125 int semihost_reset(void) {
MikamiUitOpen 0:224dccbc4edd 126 // Does not normally return, however if used with older firmware versions
MikamiUitOpen 0:224dccbc4edd 127 // that do not support this call it will return -1.
MikamiUitOpen 0:224dccbc4edd 128 return __semihost(USR_RESET, NULL);
MikamiUitOpen 0:224dccbc4edd 129 }
MikamiUitOpen 0:224dccbc4edd 130
MikamiUitOpen 0:224dccbc4edd 131 int semihost_vbus(void) {
MikamiUitOpen 0:224dccbc4edd 132 return __semihost(USR_VBUS, NULL);
MikamiUitOpen 0:224dccbc4edd 133 }
MikamiUitOpen 0:224dccbc4edd 134
MikamiUitOpen 0:224dccbc4edd 135 int semihost_powerdown(void) {
MikamiUitOpen 0:224dccbc4edd 136 return __semihost(USR_POWERDOWN, NULL);
MikamiUitOpen 0:224dccbc4edd 137 }
MikamiUitOpen 0:224dccbc4edd 138
MikamiUitOpen 0:224dccbc4edd 139 #if DEVICE_DEBUG_AWARENESS
MikamiUitOpen 0:224dccbc4edd 140
MikamiUitOpen 0:224dccbc4edd 141 int semihost_connected(void) {
MikamiUitOpen 0:224dccbc4edd 142 return (CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) ? 1 : 0;
MikamiUitOpen 0:224dccbc4edd 143 }
MikamiUitOpen 0:224dccbc4edd 144
MikamiUitOpen 0:224dccbc4edd 145 #else
MikamiUitOpen 0:224dccbc4edd 146 // These processors cannot know if the interface is connect, assume so:
MikamiUitOpen 0:224dccbc4edd 147 static int is_debugger_attached = 1;
MikamiUitOpen 0:224dccbc4edd 148
MikamiUitOpen 0:224dccbc4edd 149 int semihost_connected(void) {
MikamiUitOpen 0:224dccbc4edd 150 return is_debugger_attached;
MikamiUitOpen 0:224dccbc4edd 151 }
MikamiUitOpen 0:224dccbc4edd 152 #endif
MikamiUitOpen 0:224dccbc4edd 153
MikamiUitOpen 0:224dccbc4edd 154 int semihost_disabledebug(void) {
MikamiUitOpen 0:224dccbc4edd 155 #if !(DEVICE_DEBUG_AWARENESS)
MikamiUitOpen 0:224dccbc4edd 156 is_debugger_attached = 0;
MikamiUitOpen 0:224dccbc4edd 157 #endif
MikamiUitOpen 0:224dccbc4edd 158 return __semihost(USR_DISABLEDEBUG, NULL);
MikamiUitOpen 0:224dccbc4edd 159 }
MikamiUitOpen 0:224dccbc4edd 160
MikamiUitOpen 0:224dccbc4edd 161 #endif
MikamiUitOpen 0:224dccbc4edd 162