Output the audio signal with filtering by graphic equalizer in the *.wav file on the SD card using onboard CODEC. SD カードの *.wav ファイルのオーディオ信号をグラフィック・イコライザを通して,ボードに搭載されているCODEC で出力する.

Dependencies:   F746_GUI F746_SAI_IO SD_PlayerSkeleton FrequencyResponseDrawer

Committer:
MikamiUitOpen
Date:
Mon Apr 10 04:07:35 2017 +0000
Revision:
24:f78f9d0ac262
Parent:
16:cbb726ac20d8
25

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MikamiUitOpen 16:cbb726ac20d8 1 /* mbed Microcontroller Library
MikamiUitOpen 16:cbb726ac20d8 2 * Copyright (c) 2006-2013 ARM Limited
MikamiUitOpen 16:cbb726ac20d8 3 *
MikamiUitOpen 16:cbb726ac20d8 4 * Licensed under the Apache License, Version 2.0 (the "License");
MikamiUitOpen 16:cbb726ac20d8 5 * you may not use this file except in compliance with the License.
MikamiUitOpen 16:cbb726ac20d8 6 * You may obtain a copy of the License at
MikamiUitOpen 16:cbb726ac20d8 7 *
MikamiUitOpen 16:cbb726ac20d8 8 * http://www.apache.org/licenses/LICENSE-2.0
MikamiUitOpen 16:cbb726ac20d8 9 *
MikamiUitOpen 16:cbb726ac20d8 10 * Unless required by applicable law or agreed to in writing, software
MikamiUitOpen 16:cbb726ac20d8 11 * distributed under the License is distributed on an "AS IS" BASIS,
MikamiUitOpen 16:cbb726ac20d8 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
MikamiUitOpen 16:cbb726ac20d8 13 * See the License for the specific language governing permissions and
MikamiUitOpen 16:cbb726ac20d8 14 * limitations under the License.
MikamiUitOpen 16:cbb726ac20d8 15 */
MikamiUitOpen 16:cbb726ac20d8 16 #ifndef MBED_SERIALBASE_H
MikamiUitOpen 16:cbb726ac20d8 17 #define MBED_SERIALBASE_H
MikamiUitOpen 16:cbb726ac20d8 18
MikamiUitOpen 16:cbb726ac20d8 19 #include "platform.h"
MikamiUitOpen 16:cbb726ac20d8 20
MikamiUitOpen 16:cbb726ac20d8 21 #if DEVICE_SERIAL
MikamiUitOpen 16:cbb726ac20d8 22
MikamiUitOpen 16:cbb726ac20d8 23 #include "Stream.h"
MikamiUitOpen 16:cbb726ac20d8 24 #include "FunctionPointer.h"
MikamiUitOpen 16:cbb726ac20d8 25 #include "serial_api.h"
MikamiUitOpen 16:cbb726ac20d8 26
MikamiUitOpen 16:cbb726ac20d8 27 #if DEVICE_SERIAL_ASYNCH
MikamiUitOpen 16:cbb726ac20d8 28 #include "CThunk.h"
MikamiUitOpen 16:cbb726ac20d8 29 #include "dma_api.h"
MikamiUitOpen 16:cbb726ac20d8 30 #endif
MikamiUitOpen 16:cbb726ac20d8 31
MikamiUitOpen 16:cbb726ac20d8 32 namespace mbed {
MikamiUitOpen 16:cbb726ac20d8 33
MikamiUitOpen 16:cbb726ac20d8 34 /** A base class for serial port implementations
MikamiUitOpen 16:cbb726ac20d8 35 * Can't be instantiated directly (use Serial or RawSerial)
MikamiUitOpen 16:cbb726ac20d8 36 */
MikamiUitOpen 16:cbb726ac20d8 37 class SerialBase {
MikamiUitOpen 16:cbb726ac20d8 38
MikamiUitOpen 16:cbb726ac20d8 39 public:
MikamiUitOpen 16:cbb726ac20d8 40 /** Set the baud rate of the serial port
MikamiUitOpen 16:cbb726ac20d8 41 *
MikamiUitOpen 16:cbb726ac20d8 42 * @param baudrate The baudrate of the serial port (default = 9600).
MikamiUitOpen 16:cbb726ac20d8 43 */
MikamiUitOpen 16:cbb726ac20d8 44 void baud(int baudrate);
MikamiUitOpen 16:cbb726ac20d8 45
MikamiUitOpen 16:cbb726ac20d8 46 enum Parity {
MikamiUitOpen 16:cbb726ac20d8 47 None = 0,
MikamiUitOpen 16:cbb726ac20d8 48 Odd,
MikamiUitOpen 16:cbb726ac20d8 49 Even,
MikamiUitOpen 16:cbb726ac20d8 50 Forced1,
MikamiUitOpen 16:cbb726ac20d8 51 Forced0
MikamiUitOpen 16:cbb726ac20d8 52 };
MikamiUitOpen 16:cbb726ac20d8 53
MikamiUitOpen 16:cbb726ac20d8 54 enum IrqType {
MikamiUitOpen 16:cbb726ac20d8 55 RxIrq = 0,
MikamiUitOpen 16:cbb726ac20d8 56 TxIrq
MikamiUitOpen 16:cbb726ac20d8 57 };
MikamiUitOpen 16:cbb726ac20d8 58
MikamiUitOpen 16:cbb726ac20d8 59 enum Flow {
MikamiUitOpen 16:cbb726ac20d8 60 Disabled = 0,
MikamiUitOpen 16:cbb726ac20d8 61 RTS,
MikamiUitOpen 16:cbb726ac20d8 62 CTS,
MikamiUitOpen 16:cbb726ac20d8 63 RTSCTS
MikamiUitOpen 16:cbb726ac20d8 64 };
MikamiUitOpen 16:cbb726ac20d8 65
MikamiUitOpen 16:cbb726ac20d8 66 /** Set the transmission format used by the serial port
MikamiUitOpen 16:cbb726ac20d8 67 *
MikamiUitOpen 16:cbb726ac20d8 68 * @param bits The number of bits in a word (5-8; default = 8)
MikamiUitOpen 16:cbb726ac20d8 69 * @param parity The parity used (SerialBase::None, SerialBase::Odd, SerialBase::Even, SerialBase::Forced1, SerialBase::Forced0; default = SerialBase::None)
MikamiUitOpen 16:cbb726ac20d8 70 * @param stop The number of stop bits (1 or 2; default = 1)
MikamiUitOpen 16:cbb726ac20d8 71 */
MikamiUitOpen 16:cbb726ac20d8 72 void format(int bits=8, Parity parity=SerialBase::None, int stop_bits=1);
MikamiUitOpen 16:cbb726ac20d8 73
MikamiUitOpen 16:cbb726ac20d8 74 /** Determine if there is a character available to read
MikamiUitOpen 16:cbb726ac20d8 75 *
MikamiUitOpen 16:cbb726ac20d8 76 * @returns
MikamiUitOpen 16:cbb726ac20d8 77 * 1 if there is a character available to read,
MikamiUitOpen 16:cbb726ac20d8 78 * 0 otherwise
MikamiUitOpen 16:cbb726ac20d8 79 */
MikamiUitOpen 16:cbb726ac20d8 80 int readable();
MikamiUitOpen 16:cbb726ac20d8 81
MikamiUitOpen 16:cbb726ac20d8 82 /** Determine if there is space available to write a character
MikamiUitOpen 16:cbb726ac20d8 83 *
MikamiUitOpen 16:cbb726ac20d8 84 * @returns
MikamiUitOpen 16:cbb726ac20d8 85 * 1 if there is space to write a character,
MikamiUitOpen 16:cbb726ac20d8 86 * 0 otherwise
MikamiUitOpen 16:cbb726ac20d8 87 */
MikamiUitOpen 16:cbb726ac20d8 88 int writeable();
MikamiUitOpen 16:cbb726ac20d8 89
MikamiUitOpen 16:cbb726ac20d8 90 /** Attach a function to call whenever a serial interrupt is generated
MikamiUitOpen 16:cbb726ac20d8 91 *
MikamiUitOpen 16:cbb726ac20d8 92 * @param fptr A pointer to a void function, or 0 to set as none
MikamiUitOpen 16:cbb726ac20d8 93 * @param type Which serial interrupt to attach the member function to (Seriall::RxIrq for receive, TxIrq for transmit buffer empty)
MikamiUitOpen 16:cbb726ac20d8 94 */
MikamiUitOpen 16:cbb726ac20d8 95 void attach(void (*fptr)(void), IrqType type=RxIrq);
MikamiUitOpen 16:cbb726ac20d8 96
MikamiUitOpen 16:cbb726ac20d8 97 /** Attach a member function to call whenever a serial interrupt is generated
MikamiUitOpen 16:cbb726ac20d8 98 *
MikamiUitOpen 16:cbb726ac20d8 99 * @param tptr pointer to the object to call the member function on
MikamiUitOpen 16:cbb726ac20d8 100 * @param mptr pointer to the member function to be called
MikamiUitOpen 16:cbb726ac20d8 101 * @param type Which serial interrupt to attach the member function to (Seriall::RxIrq for receive, TxIrq for transmit buffer empty)
MikamiUitOpen 16:cbb726ac20d8 102 */
MikamiUitOpen 16:cbb726ac20d8 103 template<typename T>
MikamiUitOpen 16:cbb726ac20d8 104 void attach(T* tptr, void (T::*mptr)(void), IrqType type=RxIrq) {
MikamiUitOpen 16:cbb726ac20d8 105 if((mptr != NULL) && (tptr != NULL)) {
MikamiUitOpen 16:cbb726ac20d8 106 _irq[type].attach(tptr, mptr);
MikamiUitOpen 16:cbb726ac20d8 107 serial_irq_set(&_serial, (SerialIrq)type, 1);
MikamiUitOpen 16:cbb726ac20d8 108 } else {
MikamiUitOpen 16:cbb726ac20d8 109 serial_irq_set(&_serial, (SerialIrq)type, 0);
MikamiUitOpen 16:cbb726ac20d8 110 }
MikamiUitOpen 16:cbb726ac20d8 111 }
MikamiUitOpen 16:cbb726ac20d8 112
MikamiUitOpen 16:cbb726ac20d8 113 /** Generate a break condition on the serial line
MikamiUitOpen 16:cbb726ac20d8 114 */
MikamiUitOpen 16:cbb726ac20d8 115 void send_break();
MikamiUitOpen 16:cbb726ac20d8 116
MikamiUitOpen 16:cbb726ac20d8 117 #if DEVICE_SERIAL_FC
MikamiUitOpen 16:cbb726ac20d8 118 /** Set the flow control type on the serial port
MikamiUitOpen 16:cbb726ac20d8 119 *
MikamiUitOpen 16:cbb726ac20d8 120 * @param type the flow control type (Disabled, RTS, CTS, RTSCTS)
MikamiUitOpen 16:cbb726ac20d8 121 * @param flow1 the first flow control pin (RTS for RTS or RTSCTS, CTS for CTS)
MikamiUitOpen 16:cbb726ac20d8 122 * @param flow2 the second flow control pin (CTS for RTSCTS)
MikamiUitOpen 16:cbb726ac20d8 123 */
MikamiUitOpen 16:cbb726ac20d8 124 void set_flow_control(Flow type, PinName flow1=NC, PinName flow2=NC);
MikamiUitOpen 16:cbb726ac20d8 125 #endif
MikamiUitOpen 16:cbb726ac20d8 126
MikamiUitOpen 16:cbb726ac20d8 127 static void _irq_handler(uint32_t id, SerialIrq irq_type);
MikamiUitOpen 16:cbb726ac20d8 128
MikamiUitOpen 16:cbb726ac20d8 129 #if DEVICE_SERIAL_ASYNCH
MikamiUitOpen 16:cbb726ac20d8 130
MikamiUitOpen 16:cbb726ac20d8 131 /** Begin asynchronous write using 8bit buffer. The completition invokes registered TX event callback
MikamiUitOpen 16:cbb726ac20d8 132 *
MikamiUitOpen 16:cbb726ac20d8 133 * @param buffer The buffer where received data will be stored
MikamiUitOpen 16:cbb726ac20d8 134 * @param length The buffer length in bytes
MikamiUitOpen 16:cbb726ac20d8 135 * @param callback The event callback function
MikamiUitOpen 16:cbb726ac20d8 136 * @param event The logical OR of TX events
MikamiUitOpen 16:cbb726ac20d8 137 */
MikamiUitOpen 16:cbb726ac20d8 138 int write(const uint8_t *buffer, int length, const event_callback_t& callback, int event = SERIAL_EVENT_TX_COMPLETE);
MikamiUitOpen 16:cbb726ac20d8 139
MikamiUitOpen 16:cbb726ac20d8 140 /** Begin asynchronous write using 16bit buffer. The completition invokes registered TX event callback
MikamiUitOpen 16:cbb726ac20d8 141 *
MikamiUitOpen 16:cbb726ac20d8 142 * @param buffer The buffer where received data will be stored
MikamiUitOpen 16:cbb726ac20d8 143 * @param length The buffer length in bytes
MikamiUitOpen 16:cbb726ac20d8 144 * @param callback The event callback function
MikamiUitOpen 16:cbb726ac20d8 145 * @param event The logical OR of TX events
MikamiUitOpen 16:cbb726ac20d8 146 */
MikamiUitOpen 16:cbb726ac20d8 147 int write(const uint16_t *buffer, int length, const event_callback_t& callback, int event = SERIAL_EVENT_TX_COMPLETE);
MikamiUitOpen 16:cbb726ac20d8 148
MikamiUitOpen 16:cbb726ac20d8 149 /** Abort the on-going write transfer
MikamiUitOpen 16:cbb726ac20d8 150 */
MikamiUitOpen 16:cbb726ac20d8 151 void abort_write();
MikamiUitOpen 16:cbb726ac20d8 152
MikamiUitOpen 16:cbb726ac20d8 153 /** Begin asynchronous reading using 8bit buffer. The completition invokes registred RX event callback.
MikamiUitOpen 16:cbb726ac20d8 154 *
MikamiUitOpen 16:cbb726ac20d8 155 * @param buffer The buffer where received data will be stored
MikamiUitOpen 16:cbb726ac20d8 156 * @param length The buffer length in bytes
MikamiUitOpen 16:cbb726ac20d8 157 * @param callback The event callback function
MikamiUitOpen 16:cbb726ac20d8 158 * @param event The logical OR of RX events
MikamiUitOpen 16:cbb726ac20d8 159 * @param char_match The matching character
MikamiUitOpen 16:cbb726ac20d8 160 */
MikamiUitOpen 16:cbb726ac20d8 161 int read(uint8_t *buffer, int length, const event_callback_t& callback, int event = SERIAL_EVENT_RX_COMPLETE, unsigned char char_match = SERIAL_RESERVED_CHAR_MATCH);
MikamiUitOpen 16:cbb726ac20d8 162
MikamiUitOpen 16:cbb726ac20d8 163 /** Begin asynchronous reading using 16bit buffer. The completition invokes registred RX event callback.
MikamiUitOpen 16:cbb726ac20d8 164 *
MikamiUitOpen 16:cbb726ac20d8 165 * @param buffer The buffer where received data will be stored
MikamiUitOpen 16:cbb726ac20d8 166 * @param length The buffer length in bytes
MikamiUitOpen 16:cbb726ac20d8 167 * @param callback The event callback function
MikamiUitOpen 16:cbb726ac20d8 168 * @param event The logical OR of RX events
MikamiUitOpen 16:cbb726ac20d8 169 * @param char_match The matching character
MikamiUitOpen 16:cbb726ac20d8 170 */
MikamiUitOpen 16:cbb726ac20d8 171 int read(uint16_t *buffer, int length, const event_callback_t& callback, int event = SERIAL_EVENT_RX_COMPLETE, unsigned char char_match = SERIAL_RESERVED_CHAR_MATCH);
MikamiUitOpen 16:cbb726ac20d8 172
MikamiUitOpen 16:cbb726ac20d8 173 /** Abort the on-going read transfer
MikamiUitOpen 16:cbb726ac20d8 174 */
MikamiUitOpen 16:cbb726ac20d8 175 void abort_read();
MikamiUitOpen 16:cbb726ac20d8 176
MikamiUitOpen 16:cbb726ac20d8 177 /** Configure DMA usage suggestion for non-blocking TX transfers
MikamiUitOpen 16:cbb726ac20d8 178 *
MikamiUitOpen 16:cbb726ac20d8 179 * @param usage The usage DMA hint for peripheral
MikamiUitOpen 16:cbb726ac20d8 180 * @return Zero if the usage was set, -1 if a transaction is on-going
MikamiUitOpen 16:cbb726ac20d8 181 */
MikamiUitOpen 16:cbb726ac20d8 182 int set_dma_usage_tx(DMAUsage usage);
MikamiUitOpen 16:cbb726ac20d8 183
MikamiUitOpen 16:cbb726ac20d8 184 /** Configure DMA usage suggestion for non-blocking RX transfers
MikamiUitOpen 16:cbb726ac20d8 185 *
MikamiUitOpen 16:cbb726ac20d8 186 * @param usage The usage DMA hint for peripheral
MikamiUitOpen 16:cbb726ac20d8 187 * @return Zero if the usage was set, -1 if a transaction is on-going
MikamiUitOpen 16:cbb726ac20d8 188 */
MikamiUitOpen 16:cbb726ac20d8 189 int set_dma_usage_rx(DMAUsage usage);
MikamiUitOpen 16:cbb726ac20d8 190
MikamiUitOpen 16:cbb726ac20d8 191 protected:
MikamiUitOpen 16:cbb726ac20d8 192 void start_read(void *buffer, int buffer_size, char buffer_width, const event_callback_t& callback, int event, unsigned char char_match);
MikamiUitOpen 16:cbb726ac20d8 193 void start_write(const void *buffer, int buffer_size, char buffer_width, const event_callback_t& callback, int event);
MikamiUitOpen 16:cbb726ac20d8 194 void interrupt_handler_asynch(void);
MikamiUitOpen 16:cbb726ac20d8 195 #endif
MikamiUitOpen 16:cbb726ac20d8 196
MikamiUitOpen 16:cbb726ac20d8 197 protected:
MikamiUitOpen 16:cbb726ac20d8 198 SerialBase(PinName tx, PinName rx);
MikamiUitOpen 16:cbb726ac20d8 199 virtual ~SerialBase() {
MikamiUitOpen 16:cbb726ac20d8 200 }
MikamiUitOpen 16:cbb726ac20d8 201
MikamiUitOpen 16:cbb726ac20d8 202 int _base_getc();
MikamiUitOpen 16:cbb726ac20d8 203 int _base_putc(int c);
MikamiUitOpen 16:cbb726ac20d8 204
MikamiUitOpen 16:cbb726ac20d8 205 #if DEVICE_SERIAL_ASYNCH
MikamiUitOpen 16:cbb726ac20d8 206 CThunk<SerialBase> _thunk_irq;
MikamiUitOpen 16:cbb726ac20d8 207 event_callback_t _tx_callback;
MikamiUitOpen 16:cbb726ac20d8 208 event_callback_t _rx_callback;
MikamiUitOpen 16:cbb726ac20d8 209 DMAUsage _tx_usage;
MikamiUitOpen 16:cbb726ac20d8 210 DMAUsage _rx_usage;
MikamiUitOpen 16:cbb726ac20d8 211 #endif
MikamiUitOpen 16:cbb726ac20d8 212
MikamiUitOpen 16:cbb726ac20d8 213 serial_t _serial;
MikamiUitOpen 16:cbb726ac20d8 214 FunctionPointer _irq[2];
MikamiUitOpen 16:cbb726ac20d8 215 int _baud;
MikamiUitOpen 16:cbb726ac20d8 216
MikamiUitOpen 16:cbb726ac20d8 217 };
MikamiUitOpen 16:cbb726ac20d8 218
MikamiUitOpen 16:cbb726ac20d8 219 } // namespace mbed
MikamiUitOpen 16:cbb726ac20d8 220
MikamiUitOpen 16:cbb726ac20d8 221 #endif
MikamiUitOpen 16:cbb726ac20d8 222
MikamiUitOpen 16:cbb726ac20d8 223 #endif