Code for measuring the signal with a specified length and sampling rate, and saving it on a SD card.

Dependencies:   EALib I2S mbed

Committer:
msamadani
Date:
Thu Oct 05 17:44:39 2017 +0000
Revision:
2:8c5b6522139f
Parent:
0:c05b00be2229
A version of the code that initializes the SD RAM, activates the codec, measures the signal and saves the signal onto the SD Card.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
msamadani 0:c05b00be2229 1 /*
msamadani 0:c05b00be2229 2 * Copyright 2013 Embedded Artists AB
msamadani 0:c05b00be2229 3 *
msamadani 0:c05b00be2229 4 * Licensed under the Apache License, Version 2.0 (the "License");
msamadani 0:c05b00be2229 5 * you may not use this file except in compliance with the License.
msamadani 0:c05b00be2229 6 * You may obtain a copy of the License at
msamadani 0:c05b00be2229 7 *
msamadani 0:c05b00be2229 8 * http://www.apache.org/licenses/LICENSE-2.0
msamadani 0:c05b00be2229 9 *
msamadani 0:c05b00be2229 10 * Unless required by applicable law or agreed to in writing, software
msamadani 0:c05b00be2229 11 * distributed under the License is distributed on an "AS IS" BASIS,
msamadani 0:c05b00be2229 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
msamadani 0:c05b00be2229 13 * See the License for the specific language governing permissions and
msamadani 0:c05b00be2229 14 * limitations under the License.
msamadani 0:c05b00be2229 15 */
msamadani 0:c05b00be2229 16
msamadani 0:c05b00be2229 17 #ifndef TESTAUDIO_H
msamadani 0:c05b00be2229 18 #define TESTAUDIO_H
msamadani 0:c05b00be2229 19
msamadani 0:c05b00be2229 20 #include "WM8731.h"
msamadani 0:c05b00be2229 21 #include "I2S.h"
msamadani 0:c05b00be2229 22
msamadani 0:c05b00be2229 23 #define ECHOLENGTH 600
msamadani 0:c05b00be2229 24
msamadani 0:c05b00be2229 25
msamadani 0:c05b00be2229 26 /**
msamadani 0:c05b00be2229 27 * Test the WM8731 audio codec and the audio connectors on
msamadani 0:c05b00be2229 28 * the LPC4088 Experiment Base Board
msamadani 0:c05b00be2229 29 */
msamadani 0:c05b00be2229 30 class TestAudio {
msamadani 0:c05b00be2229 31 public:
msamadani 0:c05b00be2229 32
msamadani 0:c05b00be2229 33 /**
msamadani 0:c05b00be2229 34 * Create an interface to the audio codec
msamadani 0:c05b00be2229 35 */
msamadani 0:c05b00be2229 36 TestAudio();
msamadani 0:c05b00be2229 37
msamadani 0:c05b00be2229 38 /**
msamadani 0:c05b00be2229 39 * Test the audio
msamadani 0:c05b00be2229 40 *
msamadani 0:c05b00be2229 41 * @return true if the test was successful; otherwise false
msamadani 0:c05b00be2229 42 */
msamadani 0:c05b00be2229 43 bool runTest();
msamadani 0:c05b00be2229 44
msamadani 0:c05b00be2229 45 private:
msamadani 0:c05b00be2229 46
msamadani 0:c05b00be2229 47 /**
msamadani 0:c05b00be2229 48 * Callback function for I2S
msamadani 0:c05b00be2229 49 */
msamadani 0:c05b00be2229 50 void echo(void);
msamadani 0:c05b00be2229 51
msamadani 0:c05b00be2229 52 WM8731 _codec;
msamadani 0:c05b00be2229 53 I2S _i2sTx;
msamadani 0:c05b00be2229 54 I2S _i2sRx;
msamadani 0:c05b00be2229 55 AnalogIn _aIn;
msamadani 0:c05b00be2229 56
msamadani 0:c05b00be2229 57 int _waveIdx;
msamadani 0:c05b00be2229 58 int _echoBufPtr;
msamadani 0:c05b00be2229 59 int _echoBuf[ECHOLENGTH];
msamadani 0:c05b00be2229 60 int _txBuf[16];
msamadani 0:c05b00be2229 61 int _rxBuf[16];
msamadani 0:c05b00be2229 62 };
msamadani 0:c05b00be2229 63
msamadani 0:c05b00be2229 64 #endif
msamadani 0:c05b00be2229 65