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/SPISlave.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-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_SPISLAVE_H |
MikamiUitOpen | 16:cbb726ac20d8 | 17 | #define MBED_SPISLAVE_H |
MikamiUitOpen | 16:cbb726ac20d8 | 18 | |
MikamiUitOpen | 16:cbb726ac20d8 | 19 | #include "platform.h" |
MikamiUitOpen | 16:cbb726ac20d8 | 20 | |
MikamiUitOpen | 16:cbb726ac20d8 | 21 | #if DEVICE_SPISLAVE |
MikamiUitOpen | 16:cbb726ac20d8 | 22 | |
MikamiUitOpen | 16:cbb726ac20d8 | 23 | #include "spi_api.h" |
MikamiUitOpen | 16:cbb726ac20d8 | 24 | |
MikamiUitOpen | 16:cbb726ac20d8 | 25 | namespace mbed { |
MikamiUitOpen | 16:cbb726ac20d8 | 26 | |
MikamiUitOpen | 16:cbb726ac20d8 | 27 | /** A SPI slave, used for communicating with a SPI Master device |
MikamiUitOpen | 16:cbb726ac20d8 | 28 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 29 | * The default format is set to 8-bits, mode 0, and a clock frequency of 1MHz |
MikamiUitOpen | 16:cbb726ac20d8 | 30 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 31 | * Example: |
MikamiUitOpen | 16:cbb726ac20d8 | 32 | * @code |
MikamiUitOpen | 16:cbb726ac20d8 | 33 | * // Reply to a SPI master as slave |
MikamiUitOpen | 16:cbb726ac20d8 | 34 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 35 | * #include "mbed.h" |
MikamiUitOpen | 16:cbb726ac20d8 | 36 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 37 | * SPISlave device(p5, p6, p7, p8); // mosi, miso, sclk, ssel |
MikamiUitOpen | 16:cbb726ac20d8 | 38 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 39 | * int main() { |
MikamiUitOpen | 16:cbb726ac20d8 | 40 | * device.reply(0x00); // Prime SPI with first reply |
MikamiUitOpen | 16:cbb726ac20d8 | 41 | * while(1) { |
MikamiUitOpen | 16:cbb726ac20d8 | 42 | * if(device.receive()) { |
MikamiUitOpen | 16:cbb726ac20d8 | 43 | * int v = device.read(); // Read byte from master |
MikamiUitOpen | 16:cbb726ac20d8 | 44 | * v = (v + 1) % 0x100; // Add one to it, modulo 256 |
MikamiUitOpen | 16:cbb726ac20d8 | 45 | * device.reply(v); // Make this the next reply |
MikamiUitOpen | 16:cbb726ac20d8 | 46 | * } |
MikamiUitOpen | 16:cbb726ac20d8 | 47 | * } |
MikamiUitOpen | 16:cbb726ac20d8 | 48 | * } |
MikamiUitOpen | 16:cbb726ac20d8 | 49 | * @endcode |
MikamiUitOpen | 16:cbb726ac20d8 | 50 | */ |
MikamiUitOpen | 16:cbb726ac20d8 | 51 | class SPISlave { |
MikamiUitOpen | 16:cbb726ac20d8 | 52 | |
MikamiUitOpen | 16:cbb726ac20d8 | 53 | public: |
MikamiUitOpen | 16:cbb726ac20d8 | 54 | |
MikamiUitOpen | 16:cbb726ac20d8 | 55 | /** Create a SPI slave connected to the specified pins |
MikamiUitOpen | 16:cbb726ac20d8 | 56 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 57 | * mosi or miso can be specfied as NC if not used |
MikamiUitOpen | 16:cbb726ac20d8 | 58 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 59 | * @param mosi SPI Master Out, Slave In pin |
MikamiUitOpen | 16:cbb726ac20d8 | 60 | * @param miso SPI Master In, Slave Out pin |
MikamiUitOpen | 16:cbb726ac20d8 | 61 | * @param sclk SPI Clock pin |
MikamiUitOpen | 16:cbb726ac20d8 | 62 | * @param ssel SPI chip select pin |
MikamiUitOpen | 16:cbb726ac20d8 | 63 | */ |
MikamiUitOpen | 16:cbb726ac20d8 | 64 | SPISlave(PinName mosi, PinName miso, PinName sclk, PinName ssel); |
MikamiUitOpen | 16:cbb726ac20d8 | 65 | |
MikamiUitOpen | 16:cbb726ac20d8 | 66 | /** Configure the data transmission format |
MikamiUitOpen | 16:cbb726ac20d8 | 67 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 68 | * @param bits Number of bits per SPI frame (4 - 16) |
MikamiUitOpen | 16:cbb726ac20d8 | 69 | * @param mode Clock polarity and phase mode (0 - 3) |
MikamiUitOpen | 16:cbb726ac20d8 | 70 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 71 | * @code |
MikamiUitOpen | 16:cbb726ac20d8 | 72 | * mode | POL PHA |
MikamiUitOpen | 16:cbb726ac20d8 | 73 | * -----+-------- |
MikamiUitOpen | 16:cbb726ac20d8 | 74 | * 0 | 0 0 |
MikamiUitOpen | 16:cbb726ac20d8 | 75 | * 1 | 0 1 |
MikamiUitOpen | 16:cbb726ac20d8 | 76 | * 2 | 1 0 |
MikamiUitOpen | 16:cbb726ac20d8 | 77 | * 3 | 1 1 |
MikamiUitOpen | 16:cbb726ac20d8 | 78 | * @endcode |
MikamiUitOpen | 16:cbb726ac20d8 | 79 | */ |
MikamiUitOpen | 16:cbb726ac20d8 | 80 | void format(int bits, int mode = 0); |
MikamiUitOpen | 16:cbb726ac20d8 | 81 | |
MikamiUitOpen | 16:cbb726ac20d8 | 82 | /** Set the spi bus clock frequency |
MikamiUitOpen | 16:cbb726ac20d8 | 83 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 84 | * @param hz SCLK frequency in hz (default = 1MHz) |
MikamiUitOpen | 16:cbb726ac20d8 | 85 | */ |
MikamiUitOpen | 16:cbb726ac20d8 | 86 | void frequency(int hz = 1000000); |
MikamiUitOpen | 16:cbb726ac20d8 | 87 | |
MikamiUitOpen | 16:cbb726ac20d8 | 88 | /** Polls the SPI to see if data has been received |
MikamiUitOpen | 16:cbb726ac20d8 | 89 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 90 | * @returns |
MikamiUitOpen | 16:cbb726ac20d8 | 91 | * 0 if no data, |
MikamiUitOpen | 16:cbb726ac20d8 | 92 | * 1 otherwise |
MikamiUitOpen | 16:cbb726ac20d8 | 93 | */ |
MikamiUitOpen | 16:cbb726ac20d8 | 94 | int receive(void); |
MikamiUitOpen | 16:cbb726ac20d8 | 95 | |
MikamiUitOpen | 16:cbb726ac20d8 | 96 | /** Retrieve data from receive buffer as slave |
MikamiUitOpen | 16:cbb726ac20d8 | 97 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 98 | * @returns |
MikamiUitOpen | 16:cbb726ac20d8 | 99 | * the data in the receive buffer |
MikamiUitOpen | 16:cbb726ac20d8 | 100 | */ |
MikamiUitOpen | 16:cbb726ac20d8 | 101 | int read(void); |
MikamiUitOpen | 16:cbb726ac20d8 | 102 | |
MikamiUitOpen | 16:cbb726ac20d8 | 103 | /** Fill the transmission buffer with the value to be written out |
MikamiUitOpen | 16:cbb726ac20d8 | 104 | * as slave on the next received message from the master. |
MikamiUitOpen | 16:cbb726ac20d8 | 105 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 106 | * @param value the data to be transmitted next |
MikamiUitOpen | 16:cbb726ac20d8 | 107 | */ |
MikamiUitOpen | 16:cbb726ac20d8 | 108 | void reply(int value); |
MikamiUitOpen | 16:cbb726ac20d8 | 109 | |
MikamiUitOpen | 16:cbb726ac20d8 | 110 | protected: |
MikamiUitOpen | 16:cbb726ac20d8 | 111 | spi_t _spi; |
MikamiUitOpen | 16:cbb726ac20d8 | 112 | |
MikamiUitOpen | 16:cbb726ac20d8 | 113 | int _bits; |
MikamiUitOpen | 16:cbb726ac20d8 | 114 | int _mode; |
MikamiUitOpen | 16:cbb726ac20d8 | 115 | int _hz; |
MikamiUitOpen | 16:cbb726ac20d8 | 116 | }; |
MikamiUitOpen | 16:cbb726ac20d8 | 117 | |
MikamiUitOpen | 16:cbb726ac20d8 | 118 | } // namespace mbed |
MikamiUitOpen | 16:cbb726ac20d8 | 119 | |
MikamiUitOpen | 16:cbb726ac20d8 | 120 | #endif |
MikamiUitOpen | 16:cbb726ac20d8 | 121 | |
MikamiUitOpen | 16:cbb726ac20d8 | 122 | #endif |