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:
Sun Oct 02 10:44:58 2016 +0000
Revision:
6:38f7dce055d0
7

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MikamiUitOpen 6:38f7dce055d0 1 /* mbed Microcontroller Library
MikamiUitOpen 6:38f7dce055d0 2 * Copyright (c) 2015 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_TICKER_API_H
MikamiUitOpen 6:38f7dce055d0 17 #define MBED_TICKER_API_H
MikamiUitOpen 6:38f7dce055d0 18
MikamiUitOpen 6:38f7dce055d0 19 #include "device.h"
MikamiUitOpen 6:38f7dce055d0 20
MikamiUitOpen 6:38f7dce055d0 21 typedef uint32_t timestamp_t;
MikamiUitOpen 6:38f7dce055d0 22
MikamiUitOpen 6:38f7dce055d0 23 /** Ticker's event structure
MikamiUitOpen 6:38f7dce055d0 24 */
MikamiUitOpen 6:38f7dce055d0 25 typedef struct ticker_event_s {
MikamiUitOpen 6:38f7dce055d0 26 timestamp_t timestamp; /**< Event's timestamp */
MikamiUitOpen 6:38f7dce055d0 27 uint32_t id; /**< TimerEvent object */
MikamiUitOpen 6:38f7dce055d0 28 struct ticker_event_s *next; /**< Next event in the queue */
MikamiUitOpen 6:38f7dce055d0 29 } ticker_event_t;
MikamiUitOpen 6:38f7dce055d0 30
MikamiUitOpen 6:38f7dce055d0 31 typedef void (*ticker_event_handler)(uint32_t id);
MikamiUitOpen 6:38f7dce055d0 32
MikamiUitOpen 6:38f7dce055d0 33 /** Ticker's interface structure - required API for a ticker
MikamiUitOpen 6:38f7dce055d0 34 */
MikamiUitOpen 6:38f7dce055d0 35 typedef struct {
MikamiUitOpen 6:38f7dce055d0 36 void (*init)(void); /**< Init function */
MikamiUitOpen 6:38f7dce055d0 37 uint32_t (*read)(void); /**< Read function */
MikamiUitOpen 6:38f7dce055d0 38 void (*disable_interrupt)(void); /**< Disable interrupt function */
MikamiUitOpen 6:38f7dce055d0 39 void (*clear_interrupt)(void); /**< Clear interrupt function */
MikamiUitOpen 6:38f7dce055d0 40 void (*set_interrupt)(timestamp_t timestamp); /**< Set interrupt function */
MikamiUitOpen 6:38f7dce055d0 41 } ticker_interface_t;
MikamiUitOpen 6:38f7dce055d0 42
MikamiUitOpen 6:38f7dce055d0 43 /** Tickers events queue structure
MikamiUitOpen 6:38f7dce055d0 44 */
MikamiUitOpen 6:38f7dce055d0 45 typedef struct {
MikamiUitOpen 6:38f7dce055d0 46 ticker_event_handler event_handler; /**< Event handler */
MikamiUitOpen 6:38f7dce055d0 47 ticker_event_t *head; /**< A pointer to head */
MikamiUitOpen 6:38f7dce055d0 48 } ticker_event_queue_t;
MikamiUitOpen 6:38f7dce055d0 49
MikamiUitOpen 6:38f7dce055d0 50 /** Tickers data structure
MikamiUitOpen 6:38f7dce055d0 51 */
MikamiUitOpen 6:38f7dce055d0 52 typedef struct {
MikamiUitOpen 6:38f7dce055d0 53 const ticker_interface_t *interface; /**< Ticker's interface */
MikamiUitOpen 6:38f7dce055d0 54 ticker_event_queue_t *queue; /**< Ticker's events queue */
MikamiUitOpen 6:38f7dce055d0 55 } ticker_data_t;
MikamiUitOpen 6:38f7dce055d0 56
MikamiUitOpen 6:38f7dce055d0 57 #ifdef __cplusplus
MikamiUitOpen 6:38f7dce055d0 58 extern "C" {
MikamiUitOpen 6:38f7dce055d0 59 #endif
MikamiUitOpen 6:38f7dce055d0 60
MikamiUitOpen 6:38f7dce055d0 61 /** Initialize a ticker and sets the event handler
MikamiUitOpen 6:38f7dce055d0 62 *
MikamiUitOpen 6:38f7dce055d0 63 * @param data The ticker's data
MikamiUitOpen 6:38f7dce055d0 64 * @param handler A handler to be set
MikamiUitOpen 6:38f7dce055d0 65 */
MikamiUitOpen 6:38f7dce055d0 66 void ticker_set_handler(const ticker_data_t *const data, ticker_event_handler handler);
MikamiUitOpen 6:38f7dce055d0 67
MikamiUitOpen 6:38f7dce055d0 68 /** Irq handler which goes through the events to trigger events in the past.
MikamiUitOpen 6:38f7dce055d0 69 *
MikamiUitOpen 6:38f7dce055d0 70 * @param data The ticker's data
MikamiUitOpen 6:38f7dce055d0 71 */
MikamiUitOpen 6:38f7dce055d0 72 void ticker_irq_handler(const ticker_data_t *const data);
MikamiUitOpen 6:38f7dce055d0 73
MikamiUitOpen 6:38f7dce055d0 74 /** Remove an event from the queue
MikamiUitOpen 6:38f7dce055d0 75 *
MikamiUitOpen 6:38f7dce055d0 76 * @param data The ticker's data
MikamiUitOpen 6:38f7dce055d0 77 * @param obj The event's queue to be removed
MikamiUitOpen 6:38f7dce055d0 78 */
MikamiUitOpen 6:38f7dce055d0 79 void ticker_remove_event(const ticker_data_t *const data, ticker_event_t *obj);
MikamiUitOpen 6:38f7dce055d0 80
MikamiUitOpen 6:38f7dce055d0 81 /** Insert an event from the queue
MikamiUitOpen 6:38f7dce055d0 82 *
MikamiUitOpen 6:38f7dce055d0 83 * @param data The ticker's data
MikamiUitOpen 6:38f7dce055d0 84 * @param obj The event's queue to be removed
MikamiUitOpen 6:38f7dce055d0 85 * @param timestamp The event's timestamp
MikamiUitOpen 6:38f7dce055d0 86 * @param id The event object
MikamiUitOpen 6:38f7dce055d0 87 */
MikamiUitOpen 6:38f7dce055d0 88 void ticker_insert_event(const ticker_data_t *const data, ticker_event_t *obj, timestamp_t timestamp, uint32_t id);
MikamiUitOpen 6:38f7dce055d0 89
MikamiUitOpen 6:38f7dce055d0 90 /** Read the current ticker's timestamp
MikamiUitOpen 6:38f7dce055d0 91 *
MikamiUitOpen 6:38f7dce055d0 92 * @param data The ticker's data
MikamiUitOpen 6:38f7dce055d0 93 * @return The current timestamp
MikamiUitOpen 6:38f7dce055d0 94 */
MikamiUitOpen 6:38f7dce055d0 95 timestamp_t ticker_read(const ticker_data_t *const data);
MikamiUitOpen 6:38f7dce055d0 96
MikamiUitOpen 6:38f7dce055d0 97 /** Read the next event's timestamp
MikamiUitOpen 6:38f7dce055d0 98 *
MikamiUitOpen 6:38f7dce055d0 99 * @param data The ticker's data
MikamiUitOpen 6:38f7dce055d0 100 * @return 1 if timestamp is pending event, 0 if there's no event pending
MikamiUitOpen 6:38f7dce055d0 101 */
MikamiUitOpen 6:38f7dce055d0 102 int ticker_get_next_timestamp(const ticker_data_t *const data, timestamp_t *timestamp);
MikamiUitOpen 6:38f7dce055d0 103
MikamiUitOpen 6:38f7dce055d0 104 #ifdef __cplusplus
MikamiUitOpen 6:38f7dce055d0 105 }
MikamiUitOpen 6:38f7dce055d0 106 #endif
MikamiUitOpen 6:38f7dce055d0 107
MikamiUitOpen 6:38f7dce055d0 108 #endif