Production Test Program (PTP) for the LPC4088 Experiment Base Board

Dependencies:   EALib I2S LM75B SDFileSystem mbed

Committer:
embeddedartists
Date:
Mon Aug 25 13:15:27 2014 +0000
Revision:
0:0d5190d379d3
Child:
3:7ef908e84ae1
Baseline for PTP (production test program) for the LPC4088 QSB + Experiment Base Board.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
embeddedartists 0:0d5190d379d3 1 /*
embeddedartists 0:0d5190d379d3 2 * Copyright 2013 Embedded Artists AB
embeddedartists 0:0d5190d379d3 3 *
embeddedartists 0:0d5190d379d3 4 * Licensed under the Apache License, Version 2.0 (the "License");
embeddedartists 0:0d5190d379d3 5 * you may not use this file except in compliance with the License.
embeddedartists 0:0d5190d379d3 6 * You may obtain a copy of the License at
embeddedartists 0:0d5190d379d3 7 *
embeddedartists 0:0d5190d379d3 8 * http://www.apache.org/licenses/LICENSE-2.0
embeddedartists 0:0d5190d379d3 9 *
embeddedartists 0:0d5190d379d3 10 * Unless required by applicable law or agreed to in writing, software
embeddedartists 0:0d5190d379d3 11 * distributed under the License is distributed on an "AS IS" BASIS,
embeddedartists 0:0d5190d379d3 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
embeddedartists 0:0d5190d379d3 13 * See the License for the specific language governing permissions and
embeddedartists 0:0d5190d379d3 14 * limitations under the License.
embeddedartists 0:0d5190d379d3 15 */
embeddedartists 0:0d5190d379d3 16
embeddedartists 0:0d5190d379d3 17 /******************************************************************************
embeddedartists 0:0d5190d379d3 18 * Includes
embeddedartists 0:0d5190d379d3 19 *****************************************************************************/
embeddedartists 0:0d5190d379d3 20
embeddedartists 0:0d5190d379d3 21 #include "mbed.h"
embeddedartists 0:0d5190d379d3 22 #include "mbed_debug.h"
embeddedartists 0:0d5190d379d3 23
embeddedartists 0:0d5190d379d3 24 #include "WM8731.h"
embeddedartists 0:0d5190d379d3 25
embeddedartists 0:0d5190d379d3 26 /******************************************************************************
embeddedartists 0:0d5190d379d3 27 * Defines and typedefs
embeddedartists 0:0d5190d379d3 28 *****************************************************************************/
embeddedartists 0:0d5190d379d3 29
embeddedartists 0:0d5190d379d3 30 #define WM8731_I2C_ADDR (0x1A << 1)
embeddedartists 0:0d5190d379d3 31
embeddedartists 0:0d5190d379d3 32 #define WM8731_REG_R0_LEFT_LINE_IN 0x00
embeddedartists 0:0d5190d379d3 33 #define WM8731_REG_R1_RIGHT_LINE_IN 0x01
embeddedartists 0:0d5190d379d3 34 #define WM8731_REG_R2_LEFT_HP_OUT 0x02
embeddedartists 0:0d5190d379d3 35 #define WM8731_REG_R3_RIGHT_HP_OUT 0x03
embeddedartists 0:0d5190d379d3 36 #define WM8731_REG_R4_ANALOGUE_AUDIO_PATH_CONTROL 0x04
embeddedartists 0:0d5190d379d3 37 #define WM8731_REG_R5_DIGITAL_AUDIO_PATH_CONTROL 0x05
embeddedartists 0:0d5190d379d3 38 #define WM8731_REG_R6_POWER_DOWN_CONTROL 0x06
embeddedartists 0:0d5190d379d3 39 #define WM8731_REG_R7_DIGITAL_AUDIO_INTERFACE_FORMAT 0x07
embeddedartists 0:0d5190d379d3 40 #define WM8731_REG_R8_SAMPLING_CONTROL 0x08
embeddedartists 0:0d5190d379d3 41 #define WM8731_REG_R9_ACTIVE_CONTROL 0x09
embeddedartists 0:0d5190d379d3 42 #define WM8731_REG_R15_RESET 0x0f
embeddedartists 0:0d5190d379d3 43
embeddedartists 0:0d5190d379d3 44
embeddedartists 0:0d5190d379d3 45 WM8731::WM8731(PinName sda, PinName scl) : _i2c(sda, scl) {
embeddedartists 0:0d5190d379d3 46 }
embeddedartists 0:0d5190d379d3 47
embeddedartists 0:0d5190d379d3 48 bool WM8731::writeCmd(Register reg, uint16_t data) {
embeddedartists 0:0d5190d379d3 49 char dataToTransfer[2];
embeddedartists 0:0d5190d379d3 50
embeddedartists 0:0d5190d379d3 51 dataToTransfer[0] = (reg << 1) | ((data & 0x100) >> 8);
embeddedartists 0:0d5190d379d3 52 dataToTransfer[1] = data & 0xff;
embeddedartists 0:0d5190d379d3 53
embeddedartists 0:0d5190d379d3 54 if (_i2c.write(WM8731_I2C_ADDR, dataToTransfer, 2) == 0) {
embeddedartists 0:0d5190d379d3 55 wait_us(40);
embeddedartists 0:0d5190d379d3 56 return true;
embeddedartists 0:0d5190d379d3 57 }
embeddedartists 0:0d5190d379d3 58 return false;
embeddedartists 0:0d5190d379d3 59 }
embeddedartists 0:0d5190d379d3 60
embeddedartists 0:0d5190d379d3 61