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 <stdio.h>
MikamiUitOpen 0:224dccbc4edd 17 #include "mbed_interface.h"
MikamiUitOpen 0:224dccbc4edd 18
MikamiUitOpen 0:224dccbc4edd 19 #include "gpio_api.h"
MikamiUitOpen 0:224dccbc4edd 20 #include "wait_api.h"
MikamiUitOpen 0:224dccbc4edd 21 #include "semihost_api.h"
MikamiUitOpen 0:224dccbc4edd 22 #include "mbed_error.h"
MikamiUitOpen 0:224dccbc4edd 23 #include "toolchain.h"
MikamiUitOpen 0:224dccbc4edd 24
MikamiUitOpen 0:224dccbc4edd 25 #if DEVICE_SEMIHOST
MikamiUitOpen 0:224dccbc4edd 26
MikamiUitOpen 0:224dccbc4edd 27 // return true if a debugger is attached, indicating mbed interface is connected
MikamiUitOpen 0:224dccbc4edd 28 int mbed_interface_connected(void) {
MikamiUitOpen 0:224dccbc4edd 29 return semihost_connected();
MikamiUitOpen 0:224dccbc4edd 30 }
MikamiUitOpen 0:224dccbc4edd 31
MikamiUitOpen 0:224dccbc4edd 32 int mbed_interface_reset(void) {
MikamiUitOpen 0:224dccbc4edd 33 if (mbed_interface_connected()) {
MikamiUitOpen 0:224dccbc4edd 34 semihost_reset();
MikamiUitOpen 0:224dccbc4edd 35 return 0;
MikamiUitOpen 0:224dccbc4edd 36 } else {
MikamiUitOpen 0:224dccbc4edd 37 return -1;
MikamiUitOpen 0:224dccbc4edd 38 }
MikamiUitOpen 0:224dccbc4edd 39 }
MikamiUitOpen 0:224dccbc4edd 40
MikamiUitOpen 0:224dccbc4edd 41 WEAK int mbed_interface_uid(char *uid) {
MikamiUitOpen 0:224dccbc4edd 42 if (mbed_interface_connected()) {
MikamiUitOpen 0:224dccbc4edd 43 return semihost_uid(uid); // Returns 0 if successful, -1 on failure
MikamiUitOpen 0:224dccbc4edd 44 } else {
MikamiUitOpen 0:224dccbc4edd 45 uid[0] = 0;
MikamiUitOpen 0:224dccbc4edd 46 return -1;
MikamiUitOpen 0:224dccbc4edd 47 }
MikamiUitOpen 0:224dccbc4edd 48 }
MikamiUitOpen 0:224dccbc4edd 49
MikamiUitOpen 0:224dccbc4edd 50 int mbed_interface_disconnect(void) {
MikamiUitOpen 0:224dccbc4edd 51 int res;
MikamiUitOpen 0:224dccbc4edd 52 if (mbed_interface_connected()) {
MikamiUitOpen 0:224dccbc4edd 53 if ((res = semihost_disabledebug()) != 0)
MikamiUitOpen 0:224dccbc4edd 54 return res;
MikamiUitOpen 0:224dccbc4edd 55 while (mbed_interface_connected());
MikamiUitOpen 0:224dccbc4edd 56 return 0;
MikamiUitOpen 0:224dccbc4edd 57 } else {
MikamiUitOpen 0:224dccbc4edd 58 return -1;
MikamiUitOpen 0:224dccbc4edd 59 }
MikamiUitOpen 0:224dccbc4edd 60 }
MikamiUitOpen 0:224dccbc4edd 61
MikamiUitOpen 0:224dccbc4edd 62 int mbed_interface_powerdown(void) {
MikamiUitOpen 0:224dccbc4edd 63 int res;
MikamiUitOpen 0:224dccbc4edd 64 if (mbed_interface_connected()) {
MikamiUitOpen 0:224dccbc4edd 65 if ((res = semihost_powerdown()) != 0)
MikamiUitOpen 0:224dccbc4edd 66 return res;
MikamiUitOpen 0:224dccbc4edd 67 while (mbed_interface_connected());
MikamiUitOpen 0:224dccbc4edd 68 return 0;
MikamiUitOpen 0:224dccbc4edd 69 } else {
MikamiUitOpen 0:224dccbc4edd 70 return -1;
MikamiUitOpen 0:224dccbc4edd 71 }
MikamiUitOpen 0:224dccbc4edd 72 }
MikamiUitOpen 0:224dccbc4edd 73
MikamiUitOpen 0:224dccbc4edd 74 // for backward compatibility
MikamiUitOpen 0:224dccbc4edd 75 void mbed_reset(void) {
MikamiUitOpen 0:224dccbc4edd 76 mbed_interface_reset();
MikamiUitOpen 0:224dccbc4edd 77 }
MikamiUitOpen 0:224dccbc4edd 78
MikamiUitOpen 0:224dccbc4edd 79 WEAK int mbed_uid(char *uid) {
MikamiUitOpen 0:224dccbc4edd 80 return mbed_interface_uid(uid);
MikamiUitOpen 0:224dccbc4edd 81 }
MikamiUitOpen 0:224dccbc4edd 82 #endif
MikamiUitOpen 0:224dccbc4edd 83
MikamiUitOpen 0:224dccbc4edd 84 WEAK void mbed_mac_address(char *mac) {
MikamiUitOpen 0:224dccbc4edd 85 #if DEVICE_SEMIHOST
MikamiUitOpen 0:224dccbc4edd 86 char uid[DEVICE_ID_LENGTH + 1];
MikamiUitOpen 0:224dccbc4edd 87 int i;
MikamiUitOpen 0:224dccbc4edd 88
MikamiUitOpen 0:224dccbc4edd 89 // if we have a UID, extract the MAC
MikamiUitOpen 0:224dccbc4edd 90 if (mbed_interface_uid(uid) == 0) {
MikamiUitOpen 0:224dccbc4edd 91 char *p = uid;
MikamiUitOpen 0:224dccbc4edd 92 #if defined(DEVICE_MAC_OFFSET)
MikamiUitOpen 0:224dccbc4edd 93 p += DEVICE_MAC_OFFSET;
MikamiUitOpen 0:224dccbc4edd 94 #endif
MikamiUitOpen 0:224dccbc4edd 95 for (i=0; i<6; i++) {
MikamiUitOpen 0:224dccbc4edd 96 int byte;
MikamiUitOpen 0:224dccbc4edd 97 sscanf(p, "%2x", &byte);
MikamiUitOpen 0:224dccbc4edd 98 mac[i] = byte;
MikamiUitOpen 0:224dccbc4edd 99 p += 2;
MikamiUitOpen 0:224dccbc4edd 100 }
MikamiUitOpen 0:224dccbc4edd 101 mac[0] &= ~0x01; // reset the IG bit in the address; see IEE 802.3-2002, Section 3.2.3(b)
MikamiUitOpen 0:224dccbc4edd 102 } else { // else return a default MAC
MikamiUitOpen 0:224dccbc4edd 103 #endif
MikamiUitOpen 0:224dccbc4edd 104 mac[0] = 0x00;
MikamiUitOpen 0:224dccbc4edd 105 mac[1] = 0x02;
MikamiUitOpen 0:224dccbc4edd 106 mac[2] = 0xF7;
MikamiUitOpen 0:224dccbc4edd 107 mac[3] = 0xF0;
MikamiUitOpen 0:224dccbc4edd 108 mac[4] = 0x00;
MikamiUitOpen 0:224dccbc4edd 109 mac[5] = 0x00;
MikamiUitOpen 0:224dccbc4edd 110 #if DEVICE_SEMIHOST
MikamiUitOpen 0:224dccbc4edd 111 }
MikamiUitOpen 0:224dccbc4edd 112 #endif
MikamiUitOpen 0:224dccbc4edd 113 }