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:
Sun Oct 02 06:33:59 2016 +0000
Revision:
16:cbb726ac20d8
17

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_I2C_SLAVE_H
MikamiUitOpen 16:cbb726ac20d8 17 #define MBED_I2C_SLAVE_H
MikamiUitOpen 16:cbb726ac20d8 18
MikamiUitOpen 16:cbb726ac20d8 19 #include "platform.h"
MikamiUitOpen 16:cbb726ac20d8 20
MikamiUitOpen 16:cbb726ac20d8 21 #if DEVICE_I2CSLAVE
MikamiUitOpen 16:cbb726ac20d8 22
MikamiUitOpen 16:cbb726ac20d8 23 #include "i2c_api.h"
MikamiUitOpen 16:cbb726ac20d8 24
MikamiUitOpen 16:cbb726ac20d8 25 namespace mbed {
MikamiUitOpen 16:cbb726ac20d8 26
MikamiUitOpen 16:cbb726ac20d8 27 /** An I2C Slave, used for communicating with an I2C Master device
MikamiUitOpen 16:cbb726ac20d8 28 *
MikamiUitOpen 16:cbb726ac20d8 29 * Example:
MikamiUitOpen 16:cbb726ac20d8 30 * @code
MikamiUitOpen 16:cbb726ac20d8 31 * // Simple I2C responder
MikamiUitOpen 16:cbb726ac20d8 32 * #include <mbed.h>
MikamiUitOpen 16:cbb726ac20d8 33 *
MikamiUitOpen 16:cbb726ac20d8 34 * I2CSlave slave(p9, p10);
MikamiUitOpen 16:cbb726ac20d8 35 *
MikamiUitOpen 16:cbb726ac20d8 36 * int main() {
MikamiUitOpen 16:cbb726ac20d8 37 * char buf[10];
MikamiUitOpen 16:cbb726ac20d8 38 * char msg[] = "Slave!";
MikamiUitOpen 16:cbb726ac20d8 39 *
MikamiUitOpen 16:cbb726ac20d8 40 * slave.address(0xA0);
MikamiUitOpen 16:cbb726ac20d8 41 * while (1) {
MikamiUitOpen 16:cbb726ac20d8 42 * int i = slave.receive();
MikamiUitOpen 16:cbb726ac20d8 43 * switch (i) {
MikamiUitOpen 16:cbb726ac20d8 44 * case I2CSlave::ReadAddressed:
MikamiUitOpen 16:cbb726ac20d8 45 * slave.write(msg, strlen(msg) + 1); // Includes null char
MikamiUitOpen 16:cbb726ac20d8 46 * break;
MikamiUitOpen 16:cbb726ac20d8 47 * case I2CSlave::WriteGeneral:
MikamiUitOpen 16:cbb726ac20d8 48 * slave.read(buf, 10);
MikamiUitOpen 16:cbb726ac20d8 49 * printf("Read G: %s\n", buf);
MikamiUitOpen 16:cbb726ac20d8 50 * break;
MikamiUitOpen 16:cbb726ac20d8 51 * case I2CSlave::WriteAddressed:
MikamiUitOpen 16:cbb726ac20d8 52 * slave.read(buf, 10);
MikamiUitOpen 16:cbb726ac20d8 53 * printf("Read A: %s\n", buf);
MikamiUitOpen 16:cbb726ac20d8 54 * break;
MikamiUitOpen 16:cbb726ac20d8 55 * }
MikamiUitOpen 16:cbb726ac20d8 56 * for(int i = 0; i < 10; i++) buf[i] = 0; // Clear buffer
MikamiUitOpen 16:cbb726ac20d8 57 * }
MikamiUitOpen 16:cbb726ac20d8 58 * }
MikamiUitOpen 16:cbb726ac20d8 59 * @endcode
MikamiUitOpen 16:cbb726ac20d8 60 */
MikamiUitOpen 16:cbb726ac20d8 61 class I2CSlave {
MikamiUitOpen 16:cbb726ac20d8 62
MikamiUitOpen 16:cbb726ac20d8 63 public:
MikamiUitOpen 16:cbb726ac20d8 64 enum RxStatus {
MikamiUitOpen 16:cbb726ac20d8 65 NoData = 0,
MikamiUitOpen 16:cbb726ac20d8 66 ReadAddressed = 1,
MikamiUitOpen 16:cbb726ac20d8 67 WriteGeneral = 2,
MikamiUitOpen 16:cbb726ac20d8 68 WriteAddressed = 3
MikamiUitOpen 16:cbb726ac20d8 69 };
MikamiUitOpen 16:cbb726ac20d8 70
MikamiUitOpen 16:cbb726ac20d8 71 /** Create an I2C Slave interface, connected to the specified pins.
MikamiUitOpen 16:cbb726ac20d8 72 *
MikamiUitOpen 16:cbb726ac20d8 73 * @param sda I2C data line pin
MikamiUitOpen 16:cbb726ac20d8 74 * @param scl I2C clock line pin
MikamiUitOpen 16:cbb726ac20d8 75 */
MikamiUitOpen 16:cbb726ac20d8 76 I2CSlave(PinName sda, PinName scl);
MikamiUitOpen 16:cbb726ac20d8 77
MikamiUitOpen 16:cbb726ac20d8 78 /** Set the frequency of the I2C interface
MikamiUitOpen 16:cbb726ac20d8 79 *
MikamiUitOpen 16:cbb726ac20d8 80 * @param hz The bus frequency in hertz
MikamiUitOpen 16:cbb726ac20d8 81 */
MikamiUitOpen 16:cbb726ac20d8 82 void frequency(int hz);
MikamiUitOpen 16:cbb726ac20d8 83
MikamiUitOpen 16:cbb726ac20d8 84 /** Checks to see if this I2C Slave has been addressed.
MikamiUitOpen 16:cbb726ac20d8 85 *
MikamiUitOpen 16:cbb726ac20d8 86 * @returns
MikamiUitOpen 16:cbb726ac20d8 87 * A status indicating if the device has been addressed, and how
MikamiUitOpen 16:cbb726ac20d8 88 * - NoData - the slave has not been addressed
MikamiUitOpen 16:cbb726ac20d8 89 * - ReadAddressed - the master has requested a read from this slave
MikamiUitOpen 16:cbb726ac20d8 90 * - WriteAddressed - the master is writing to this slave
MikamiUitOpen 16:cbb726ac20d8 91 * - WriteGeneral - the master is writing to all slave
MikamiUitOpen 16:cbb726ac20d8 92 */
MikamiUitOpen 16:cbb726ac20d8 93 int receive(void);
MikamiUitOpen 16:cbb726ac20d8 94
MikamiUitOpen 16:cbb726ac20d8 95 /** Read from an I2C master.
MikamiUitOpen 16:cbb726ac20d8 96 *
MikamiUitOpen 16:cbb726ac20d8 97 * @param data pointer to the byte array to read data in to
MikamiUitOpen 16:cbb726ac20d8 98 * @param length maximum number of bytes to read
MikamiUitOpen 16:cbb726ac20d8 99 *
MikamiUitOpen 16:cbb726ac20d8 100 * @returns
MikamiUitOpen 16:cbb726ac20d8 101 * 0 on success,
MikamiUitOpen 16:cbb726ac20d8 102 * non-0 otherwise
MikamiUitOpen 16:cbb726ac20d8 103 */
MikamiUitOpen 16:cbb726ac20d8 104 int read(char *data, int length);
MikamiUitOpen 16:cbb726ac20d8 105
MikamiUitOpen 16:cbb726ac20d8 106 /** Read a single byte from an I2C master.
MikamiUitOpen 16:cbb726ac20d8 107 *
MikamiUitOpen 16:cbb726ac20d8 108 * @returns
MikamiUitOpen 16:cbb726ac20d8 109 * the byte read
MikamiUitOpen 16:cbb726ac20d8 110 */
MikamiUitOpen 16:cbb726ac20d8 111 int read(void);
MikamiUitOpen 16:cbb726ac20d8 112
MikamiUitOpen 16:cbb726ac20d8 113 /** Write to an I2C master.
MikamiUitOpen 16:cbb726ac20d8 114 *
MikamiUitOpen 16:cbb726ac20d8 115 * @param data pointer to the byte array to be transmitted
MikamiUitOpen 16:cbb726ac20d8 116 * @param length the number of bytes to transmite
MikamiUitOpen 16:cbb726ac20d8 117 *
MikamiUitOpen 16:cbb726ac20d8 118 * @returns
MikamiUitOpen 16:cbb726ac20d8 119 * 0 on success,
MikamiUitOpen 16:cbb726ac20d8 120 * non-0 otherwise
MikamiUitOpen 16:cbb726ac20d8 121 */
MikamiUitOpen 16:cbb726ac20d8 122 int write(const char *data, int length);
MikamiUitOpen 16:cbb726ac20d8 123
MikamiUitOpen 16:cbb726ac20d8 124 /** Write a single byte to an I2C master.
MikamiUitOpen 16:cbb726ac20d8 125 *
MikamiUitOpen 16:cbb726ac20d8 126 * @data the byte to write
MikamiUitOpen 16:cbb726ac20d8 127 *
MikamiUitOpen 16:cbb726ac20d8 128 * @returns
MikamiUitOpen 16:cbb726ac20d8 129 * '1' if an ACK was received,
MikamiUitOpen 16:cbb726ac20d8 130 * '0' otherwise
MikamiUitOpen 16:cbb726ac20d8 131 */
MikamiUitOpen 16:cbb726ac20d8 132 int write(int data);
MikamiUitOpen 16:cbb726ac20d8 133
MikamiUitOpen 16:cbb726ac20d8 134 /** Sets the I2C slave address.
MikamiUitOpen 16:cbb726ac20d8 135 *
MikamiUitOpen 16:cbb726ac20d8 136 * @param address The address to set for the slave (ignoring the least
MikamiUitOpen 16:cbb726ac20d8 137 * signifcant bit). If set to 0, the slave will only respond to the
MikamiUitOpen 16:cbb726ac20d8 138 * general call address.
MikamiUitOpen 16:cbb726ac20d8 139 */
MikamiUitOpen 16:cbb726ac20d8 140 void address(int address);
MikamiUitOpen 16:cbb726ac20d8 141
MikamiUitOpen 16:cbb726ac20d8 142 /** Reset the I2C slave back into the known ready receiving state.
MikamiUitOpen 16:cbb726ac20d8 143 */
MikamiUitOpen 16:cbb726ac20d8 144 void stop(void);
MikamiUitOpen 16:cbb726ac20d8 145
MikamiUitOpen 16:cbb726ac20d8 146 protected:
MikamiUitOpen 16:cbb726ac20d8 147 i2c_t _i2c;
MikamiUitOpen 16:cbb726ac20d8 148 };
MikamiUitOpen 16:cbb726ac20d8 149
MikamiUitOpen 16:cbb726ac20d8 150 } // namespace mbed
MikamiUitOpen 16:cbb726ac20d8 151
MikamiUitOpen 16:cbb726ac20d8 152 #endif
MikamiUitOpen 16:cbb726ac20d8 153
MikamiUitOpen 16:cbb726ac20d8 154 #endif