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

Dependencies:   EALib I2S LM75B SDFileSystem mbed

WM8731.h

Committer:
embeddedartists
Date:
2014-08-25
Revision:
0:0d5190d379d3
Child:
3:7ef908e84ae1

File content as of revision 0:0d5190d379d3:

/*
 *  Copyright 2013 Embedded Artists AB
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

#ifndef WM8731_H
#define WM8731_H


/**
 * Wolfson Mgiroelectronics Audio Codec WM8731.
 */
class WM8731 {
public:

    /** Registers */
    enum Register {
        REG_R0_LEFT_LINE_IN                   = 0x00,
        REG_R1_RIGHT_LINE_IN                  = 0x01,
        REG_R2_LEFT_HP_OUT                    = 0x02,
        REG_R3_RIGHT_HP_OUT                   = 0x03,
        REG_R4_ANALOGUE_AUDIO_PATH_CONTROL    = 0x04,
        REG_R5_DIGITAL_AUDIO_PATH_CONTROL     = 0x05,
        REG_R6_POWER_DOWN_CONTROL             = 0x06,
        REG_R7_DIGITAL_AUDIO_INTERFACE_FORMAT = 0x07,
        REG_R8_SAMPLING_CONTROL               = 0x08,
        REG_R9_ACTIVE_CONTROL                 = 0x09,
        REG_R15_RESET                         = 0x0f
    };
	
    /**
     * Create an interface to the WM8731 accelerometer
     *
     * @param sda I2C data line pin
     * @param scl I2C clock line pin
     */
    WM8731(PinName sda, PinName scl);

    /**
     * Write data to the specified address.
     *
     * @param reg   register to write to
     * @param data  data to write
	 *
     * @return true if command was successful; otherwise false
     */
	bool writeCmd(Register reg, uint16_t data);

private:

    I2C _i2c;
};

#endif