Realtime spectrogram for DISCO-F746NG. On-board MEMS microphone is used for input sound signal. リアルタイムスペクトログラム.入力:MEMSマイク

Dependencies:   F746_GUI F746_SAI_IO UIT_FFT_Real

Committer:
MikamiUitOpen
Date:
Mon Apr 10 13:43:07 2017 +0000
Revision:
6:b3885567877c
Parent:
4:c1beacfc42c7
7

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 #include "rtc_api.h"
MikamiUitOpen 4:c1beacfc42c7 17
MikamiUitOpen 4:c1beacfc42c7 18 #include <time.h>
MikamiUitOpen 4:c1beacfc42c7 19 #include "rtc_time.h"
MikamiUitOpen 4:c1beacfc42c7 20 #include "us_ticker_api.h"
MikamiUitOpen 4:c1beacfc42c7 21
MikamiUitOpen 4:c1beacfc42c7 22 #if DEVICE_RTC
MikamiUitOpen 4:c1beacfc42c7 23 static void (*_rtc_init)(void) = rtc_init;
MikamiUitOpen 4:c1beacfc42c7 24 static int (*_rtc_isenabled)(void) = rtc_isenabled;
MikamiUitOpen 4:c1beacfc42c7 25 static time_t (*_rtc_read)(void) = rtc_read;
MikamiUitOpen 4:c1beacfc42c7 26 static void (*_rtc_write)(time_t t) = rtc_write;
MikamiUitOpen 4:c1beacfc42c7 27 #else
MikamiUitOpen 4:c1beacfc42c7 28 static void (*_rtc_init)(void) = NULL;
MikamiUitOpen 4:c1beacfc42c7 29 static int (*_rtc_isenabled)(void) = NULL;
MikamiUitOpen 4:c1beacfc42c7 30 static time_t (*_rtc_read)(void) = NULL;
MikamiUitOpen 4:c1beacfc42c7 31 static void (*_rtc_write)(time_t t) = NULL;
MikamiUitOpen 4:c1beacfc42c7 32 #endif
MikamiUitOpen 4:c1beacfc42c7 33
MikamiUitOpen 4:c1beacfc42c7 34 #ifdef __cplusplus
MikamiUitOpen 4:c1beacfc42c7 35 extern "C" {
MikamiUitOpen 4:c1beacfc42c7 36 #endif
MikamiUitOpen 4:c1beacfc42c7 37 #if defined (__ICCARM__)
MikamiUitOpen 4:c1beacfc42c7 38 time_t __time32(time_t *timer)
MikamiUitOpen 4:c1beacfc42c7 39 #else
MikamiUitOpen 4:c1beacfc42c7 40 time_t time(time_t *timer)
MikamiUitOpen 4:c1beacfc42c7 41 #endif
MikamiUitOpen 4:c1beacfc42c7 42
MikamiUitOpen 4:c1beacfc42c7 43 {
MikamiUitOpen 4:c1beacfc42c7 44 if (_rtc_isenabled != NULL) {
MikamiUitOpen 4:c1beacfc42c7 45 if (!(_rtc_isenabled())) {
MikamiUitOpen 4:c1beacfc42c7 46 set_time(0);
MikamiUitOpen 4:c1beacfc42c7 47 }
MikamiUitOpen 4:c1beacfc42c7 48 }
MikamiUitOpen 4:c1beacfc42c7 49
MikamiUitOpen 4:c1beacfc42c7 50 time_t t = 0;
MikamiUitOpen 4:c1beacfc42c7 51 if (_rtc_read != NULL) {
MikamiUitOpen 4:c1beacfc42c7 52 t = _rtc_read();
MikamiUitOpen 4:c1beacfc42c7 53 }
MikamiUitOpen 4:c1beacfc42c7 54
MikamiUitOpen 4:c1beacfc42c7 55 if (timer != NULL) {
MikamiUitOpen 4:c1beacfc42c7 56 *timer = t;
MikamiUitOpen 4:c1beacfc42c7 57 }
MikamiUitOpen 4:c1beacfc42c7 58 return t;
MikamiUitOpen 4:c1beacfc42c7 59 }
MikamiUitOpen 4:c1beacfc42c7 60
MikamiUitOpen 4:c1beacfc42c7 61 void set_time(time_t t) {
MikamiUitOpen 4:c1beacfc42c7 62 if (_rtc_init != NULL) {
MikamiUitOpen 4:c1beacfc42c7 63 _rtc_init();
MikamiUitOpen 4:c1beacfc42c7 64 }
MikamiUitOpen 4:c1beacfc42c7 65 if (_rtc_write != NULL) {
MikamiUitOpen 4:c1beacfc42c7 66 _rtc_write(t);
MikamiUitOpen 4:c1beacfc42c7 67 }
MikamiUitOpen 4:c1beacfc42c7 68 }
MikamiUitOpen 4:c1beacfc42c7 69
MikamiUitOpen 4:c1beacfc42c7 70 clock_t clock() {
MikamiUitOpen 4:c1beacfc42c7 71 clock_t t = us_ticker_read();
MikamiUitOpen 4:c1beacfc42c7 72 t /= 1000000 / CLOCKS_PER_SEC; // convert to processor time
MikamiUitOpen 4:c1beacfc42c7 73 return t;
MikamiUitOpen 4:c1beacfc42c7 74 }
MikamiUitOpen 4:c1beacfc42c7 75
MikamiUitOpen 4:c1beacfc42c7 76 void attach_rtc(time_t (*read_rtc)(void), void (*write_rtc)(time_t), void (*init_rtc)(void), int (*isenabled_rtc)(void)) {
MikamiUitOpen 4:c1beacfc42c7 77 __disable_irq();
MikamiUitOpen 4:c1beacfc42c7 78 _rtc_read = read_rtc;
MikamiUitOpen 4:c1beacfc42c7 79 _rtc_write = write_rtc;
MikamiUitOpen 4:c1beacfc42c7 80 _rtc_init = init_rtc;
MikamiUitOpen 4:c1beacfc42c7 81 _rtc_isenabled = isenabled_rtc;
MikamiUitOpen 4:c1beacfc42c7 82 __enable_irq();
MikamiUitOpen 4:c1beacfc42c7 83 }
MikamiUitOpen 4:c1beacfc42c7 84
MikamiUitOpen 4:c1beacfc42c7 85
MikamiUitOpen 4:c1beacfc42c7 86
MikamiUitOpen 4:c1beacfc42c7 87 #ifdef __cplusplus
MikamiUitOpen 4:c1beacfc42c7 88 }
MikamiUitOpen 4:c1beacfc42c7 89 #endif