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
mbed_src_STM32F7/api/I2C.h@24:f78f9d0ac262, 2017-04-10 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Mon Apr 10 04:07:35 2017 +0000
- Revision:
- 24:f78f9d0ac262
- Parent:
- 16:cbb726ac20d8
25
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MikamiUitOpen | 16:cbb726ac20d8 | 1 | /* mbed Microcontroller Library |
MikamiUitOpen | 16:cbb726ac20d8 | 2 | * Copyright (c) 2006-2015 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_I2C_H |
MikamiUitOpen | 16:cbb726ac20d8 | 17 | #define MBED_I2C_H |
MikamiUitOpen | 16:cbb726ac20d8 | 18 | |
MikamiUitOpen | 16:cbb726ac20d8 | 19 | #include "platform.h" |
MikamiUitOpen | 16:cbb726ac20d8 | 20 | |
MikamiUitOpen | 16:cbb726ac20d8 | 21 | #if DEVICE_I2C |
MikamiUitOpen | 16:cbb726ac20d8 | 22 | |
MikamiUitOpen | 16:cbb726ac20d8 | 23 | #include "i2c_api.h" |
MikamiUitOpen | 16:cbb726ac20d8 | 24 | |
MikamiUitOpen | 16:cbb726ac20d8 | 25 | #if DEVICE_I2C_ASYNCH |
MikamiUitOpen | 16:cbb726ac20d8 | 26 | #include "CThunk.h" |
MikamiUitOpen | 16:cbb726ac20d8 | 27 | #include "dma_api.h" |
MikamiUitOpen | 16:cbb726ac20d8 | 28 | #include "FunctionPointer.h" |
MikamiUitOpen | 16:cbb726ac20d8 | 29 | #endif |
MikamiUitOpen | 16:cbb726ac20d8 | 30 | |
MikamiUitOpen | 16:cbb726ac20d8 | 31 | namespace mbed { |
MikamiUitOpen | 16:cbb726ac20d8 | 32 | |
MikamiUitOpen | 16:cbb726ac20d8 | 33 | /** An I2C Master, used for communicating with I2C slave devices |
MikamiUitOpen | 16:cbb726ac20d8 | 34 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 35 | * Example: |
MikamiUitOpen | 16:cbb726ac20d8 | 36 | * @code |
MikamiUitOpen | 16:cbb726ac20d8 | 37 | * // Read from I2C slave at address 0x62 |
MikamiUitOpen | 16:cbb726ac20d8 | 38 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 39 | * #include "mbed.h" |
MikamiUitOpen | 16:cbb726ac20d8 | 40 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 41 | * I2C i2c(p28, p27); |
MikamiUitOpen | 16:cbb726ac20d8 | 42 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 43 | * int main() { |
MikamiUitOpen | 16:cbb726ac20d8 | 44 | * int address = 0x62; |
MikamiUitOpen | 16:cbb726ac20d8 | 45 | * char data[2]; |
MikamiUitOpen | 16:cbb726ac20d8 | 46 | * i2c.read(address, data, 2); |
MikamiUitOpen | 16:cbb726ac20d8 | 47 | * } |
MikamiUitOpen | 16:cbb726ac20d8 | 48 | * @endcode |
MikamiUitOpen | 16:cbb726ac20d8 | 49 | */ |
MikamiUitOpen | 16:cbb726ac20d8 | 50 | class I2C { |
MikamiUitOpen | 16:cbb726ac20d8 | 51 | |
MikamiUitOpen | 16:cbb726ac20d8 | 52 | public: |
MikamiUitOpen | 16:cbb726ac20d8 | 53 | enum RxStatus { |
MikamiUitOpen | 16:cbb726ac20d8 | 54 | NoData, |
MikamiUitOpen | 16:cbb726ac20d8 | 55 | MasterGeneralCall, |
MikamiUitOpen | 16:cbb726ac20d8 | 56 | MasterWrite, |
MikamiUitOpen | 16:cbb726ac20d8 | 57 | MasterRead |
MikamiUitOpen | 16:cbb726ac20d8 | 58 | }; |
MikamiUitOpen | 16:cbb726ac20d8 | 59 | |
MikamiUitOpen | 16:cbb726ac20d8 | 60 | enum Acknowledge { |
MikamiUitOpen | 16:cbb726ac20d8 | 61 | NoACK = 0, |
MikamiUitOpen | 16:cbb726ac20d8 | 62 | ACK = 1 |
MikamiUitOpen | 16:cbb726ac20d8 | 63 | }; |
MikamiUitOpen | 16:cbb726ac20d8 | 64 | |
MikamiUitOpen | 16:cbb726ac20d8 | 65 | /** Create an I2C Master interface, connected to the specified pins |
MikamiUitOpen | 16:cbb726ac20d8 | 66 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 67 | * @param sda I2C data line pin |
MikamiUitOpen | 16:cbb726ac20d8 | 68 | * @param scl I2C clock line pin |
MikamiUitOpen | 16:cbb726ac20d8 | 69 | */ |
MikamiUitOpen | 16:cbb726ac20d8 | 70 | I2C(PinName sda, PinName scl); |
MikamiUitOpen | 16:cbb726ac20d8 | 71 | |
MikamiUitOpen | 16:cbb726ac20d8 | 72 | /** Set the frequency of the I2C interface |
MikamiUitOpen | 16:cbb726ac20d8 | 73 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 74 | * @param hz The bus frequency in hertz |
MikamiUitOpen | 16:cbb726ac20d8 | 75 | */ |
MikamiUitOpen | 16:cbb726ac20d8 | 76 | void frequency(int hz); |
MikamiUitOpen | 16:cbb726ac20d8 | 77 | |
MikamiUitOpen | 16:cbb726ac20d8 | 78 | /** Read from an I2C slave |
MikamiUitOpen | 16:cbb726ac20d8 | 79 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 80 | * Performs a complete read transaction. The bottom bit of |
MikamiUitOpen | 16:cbb726ac20d8 | 81 | * the address is forced to 1 to indicate a read. |
MikamiUitOpen | 16:cbb726ac20d8 | 82 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 83 | * @param address 8-bit I2C slave address [ addr | 1 ] |
MikamiUitOpen | 16:cbb726ac20d8 | 84 | * @param data Pointer to the byte-array to read data in to |
MikamiUitOpen | 16:cbb726ac20d8 | 85 | * @param length Number of bytes to read |
MikamiUitOpen | 16:cbb726ac20d8 | 86 | * @param repeated Repeated start, true - don't send stop at end |
MikamiUitOpen | 16:cbb726ac20d8 | 87 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 88 | * @returns |
MikamiUitOpen | 16:cbb726ac20d8 | 89 | * 0 on success (ack), |
MikamiUitOpen | 16:cbb726ac20d8 | 90 | * non-0 on failure (nack) |
MikamiUitOpen | 16:cbb726ac20d8 | 91 | */ |
MikamiUitOpen | 16:cbb726ac20d8 | 92 | int read(int address, char *data, int length, bool repeated = false); |
MikamiUitOpen | 16:cbb726ac20d8 | 93 | |
MikamiUitOpen | 16:cbb726ac20d8 | 94 | /** Read a single byte from the I2C bus |
MikamiUitOpen | 16:cbb726ac20d8 | 95 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 96 | * @param ack indicates if the byte is to be acknowledged (1 = acknowledge) |
MikamiUitOpen | 16:cbb726ac20d8 | 97 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 98 | * @returns |
MikamiUitOpen | 16:cbb726ac20d8 | 99 | * the byte read |
MikamiUitOpen | 16:cbb726ac20d8 | 100 | */ |
MikamiUitOpen | 16:cbb726ac20d8 | 101 | int read(int ack); |
MikamiUitOpen | 16:cbb726ac20d8 | 102 | |
MikamiUitOpen | 16:cbb726ac20d8 | 103 | /** Write to an I2C slave |
MikamiUitOpen | 16:cbb726ac20d8 | 104 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 105 | * Performs a complete write transaction. The bottom bit of |
MikamiUitOpen | 16:cbb726ac20d8 | 106 | * the address is forced to 0 to indicate a write. |
MikamiUitOpen | 16:cbb726ac20d8 | 107 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 108 | * @param address 8-bit I2C slave address [ addr | 0 ] |
MikamiUitOpen | 16:cbb726ac20d8 | 109 | * @param data Pointer to the byte-array data to send |
MikamiUitOpen | 16:cbb726ac20d8 | 110 | * @param length Number of bytes to send |
MikamiUitOpen | 16:cbb726ac20d8 | 111 | * @param repeated Repeated start, true - do not send stop at end |
MikamiUitOpen | 16:cbb726ac20d8 | 112 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 113 | * @returns |
MikamiUitOpen | 16:cbb726ac20d8 | 114 | * 0 on success (ack), |
MikamiUitOpen | 16:cbb726ac20d8 | 115 | * non-0 on failure (nack) |
MikamiUitOpen | 16:cbb726ac20d8 | 116 | */ |
MikamiUitOpen | 16:cbb726ac20d8 | 117 | int write(int address, const char *data, int length, bool repeated = false); |
MikamiUitOpen | 16:cbb726ac20d8 | 118 | |
MikamiUitOpen | 16:cbb726ac20d8 | 119 | /** Write single byte out on the I2C bus |
MikamiUitOpen | 16:cbb726ac20d8 | 120 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 121 | * @param data data to write out on bus |
MikamiUitOpen | 16:cbb726ac20d8 | 122 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 123 | * @returns |
MikamiUitOpen | 16:cbb726ac20d8 | 124 | * '1' if an ACK was received, |
MikamiUitOpen | 16:cbb726ac20d8 | 125 | * '0' otherwise |
MikamiUitOpen | 16:cbb726ac20d8 | 126 | */ |
MikamiUitOpen | 16:cbb726ac20d8 | 127 | int write(int data); |
MikamiUitOpen | 16:cbb726ac20d8 | 128 | |
MikamiUitOpen | 16:cbb726ac20d8 | 129 | /** Creates a start condition on the I2C bus |
MikamiUitOpen | 16:cbb726ac20d8 | 130 | */ |
MikamiUitOpen | 16:cbb726ac20d8 | 131 | |
MikamiUitOpen | 16:cbb726ac20d8 | 132 | void start(void); |
MikamiUitOpen | 16:cbb726ac20d8 | 133 | |
MikamiUitOpen | 16:cbb726ac20d8 | 134 | /** Creates a stop condition on the I2C bus |
MikamiUitOpen | 16:cbb726ac20d8 | 135 | */ |
MikamiUitOpen | 16:cbb726ac20d8 | 136 | void stop(void); |
MikamiUitOpen | 16:cbb726ac20d8 | 137 | |
MikamiUitOpen | 16:cbb726ac20d8 | 138 | #if DEVICE_I2C_ASYNCH |
MikamiUitOpen | 16:cbb726ac20d8 | 139 | |
MikamiUitOpen | 16:cbb726ac20d8 | 140 | /** Start non-blocking I2C transfer. |
MikamiUitOpen | 16:cbb726ac20d8 | 141 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 142 | * @param address 8/10 bit I2c slave address |
MikamiUitOpen | 16:cbb726ac20d8 | 143 | * @param tx_buffer The TX buffer with data to be transfered |
MikamiUitOpen | 16:cbb726ac20d8 | 144 | * @param tx_length The length of TX buffer in bytes |
MikamiUitOpen | 16:cbb726ac20d8 | 145 | * @param rx_buffer The RX buffer which is used for received data |
MikamiUitOpen | 16:cbb726ac20d8 | 146 | * @param rx_length The length of RX buffer in bytes |
MikamiUitOpen | 16:cbb726ac20d8 | 147 | * @param event The logical OR of events to modify |
MikamiUitOpen | 16:cbb726ac20d8 | 148 | * @param callback The event callback function |
MikamiUitOpen | 16:cbb726ac20d8 | 149 | * @param repeated Repeated start, true - do not send stop at end |
MikamiUitOpen | 16:cbb726ac20d8 | 150 | * @return Zero if the transfer has started, or -1 if I2C peripheral is busy |
MikamiUitOpen | 16:cbb726ac20d8 | 151 | */ |
MikamiUitOpen | 16:cbb726ac20d8 | 152 | int transfer(int address, const char *tx_buffer, int tx_length, char *rx_buffer, int rx_length, const event_callback_t& callback, int event = I2C_EVENT_TRANSFER_COMPLETE, bool repeated = false); |
MikamiUitOpen | 16:cbb726ac20d8 | 153 | |
MikamiUitOpen | 16:cbb726ac20d8 | 154 | /** Abort the on-going I2C transfer |
MikamiUitOpen | 16:cbb726ac20d8 | 155 | */ |
MikamiUitOpen | 16:cbb726ac20d8 | 156 | void abort_transfer(); |
MikamiUitOpen | 16:cbb726ac20d8 | 157 | protected: |
MikamiUitOpen | 16:cbb726ac20d8 | 158 | void irq_handler_asynch(void); |
MikamiUitOpen | 16:cbb726ac20d8 | 159 | event_callback_t _callback; |
MikamiUitOpen | 16:cbb726ac20d8 | 160 | CThunk<I2C> _irq; |
MikamiUitOpen | 16:cbb726ac20d8 | 161 | DMAUsage _usage; |
MikamiUitOpen | 16:cbb726ac20d8 | 162 | #endif |
MikamiUitOpen | 16:cbb726ac20d8 | 163 | |
MikamiUitOpen | 16:cbb726ac20d8 | 164 | protected: |
MikamiUitOpen | 16:cbb726ac20d8 | 165 | void aquire(); |
MikamiUitOpen | 16:cbb726ac20d8 | 166 | |
MikamiUitOpen | 16:cbb726ac20d8 | 167 | i2c_t _i2c; |
MikamiUitOpen | 16:cbb726ac20d8 | 168 | static I2C *_owner; |
MikamiUitOpen | 16:cbb726ac20d8 | 169 | int _hz; |
MikamiUitOpen | 16:cbb726ac20d8 | 170 | }; |
MikamiUitOpen | 16:cbb726ac20d8 | 171 | |
MikamiUitOpen | 16:cbb726ac20d8 | 172 | } // namespace mbed |
MikamiUitOpen | 16:cbb726ac20d8 | 173 | |
MikamiUitOpen | 16:cbb726ac20d8 | 174 | #endif |
MikamiUitOpen | 16:cbb726ac20d8 | 175 | |
MikamiUitOpen | 16:cbb726ac20d8 | 176 | #endif |