Device driver for TI TLV320AIC1110 voice band codec

Work in Progress

Committer:
sam_grove
Date:
Tue May 21 15:16:44 2013 +0000
Revision:
5:174f94df7624
Parent:
4:470f89e786f9
added comments

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sam_grove 0:ec233f3b49d8 1 /**
sam_grove 0:ec233f3b49d8 2 * @file TLV320AIC1110.h
sam_grove 0:ec233f3b49d8 3 * @brief Device driver - TLV320AIC1110 CODEC
sam_grove 0:ec233f3b49d8 4 * @author sam grove
sam_grove 0:ec233f3b49d8 5 * @version 1.0
sam_grove 0:ec233f3b49d8 6 * @see http://www.ti.com/product/tlv320aic1110
sam_grove 0:ec233f3b49d8 7 *
sam_grove 0:ec233f3b49d8 8 * Copyright (c) 2013
sam_grove 0:ec233f3b49d8 9 *
sam_grove 0:ec233f3b49d8 10 * Licensed under the Apache License, Version 2.0 (the "License");
sam_grove 0:ec233f3b49d8 11 * you may not use this file except in compliance with the License.
sam_grove 0:ec233f3b49d8 12 * You may obtain a copy of the License at
sam_grove 0:ec233f3b49d8 13 *
sam_grove 0:ec233f3b49d8 14 * http://www.apache.org/licenses/LICENSE-2.0
sam_grove 0:ec233f3b49d8 15 *
sam_grove 0:ec233f3b49d8 16 * Unless required by applicable law or agreed to in writing, software
sam_grove 0:ec233f3b49d8 17 * distributed under the License is distributed on an "AS IS" BASIS,
sam_grove 0:ec233f3b49d8 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
sam_grove 0:ec233f3b49d8 19 * See the License for the specific language governing permissions and
sam_grove 0:ec233f3b49d8 20 * limitations under the License.
sam_grove 0:ec233f3b49d8 21 */
sam_grove 0:ec233f3b49d8 22
sam_grove 0:ec233f3b49d8 23 #ifndef TLV320AIC1110_H
sam_grove 0:ec233f3b49d8 24 #define TLV320AIC1110_H
sam_grove 0:ec233f3b49d8 25
sam_grove 0:ec233f3b49d8 26 #include "mbed.h"
sam_grove 0:ec233f3b49d8 27
sam_grove 0:ec233f3b49d8 28 /** Using the TI TLV320AIC1110 audio CODEC
sam_grove 0:ec233f3b49d8 29 *
sam_grove 0:ec233f3b49d8 30 * Example:
sam_grove 0:ec233f3b49d8 31 * @code
sam_grove 0:ec233f3b49d8 32
sam_grove 0:ec233f3b49d8 33 * @endcode
sam_grove 0:ec233f3b49d8 34 */
sam_grove 0:ec233f3b49d8 35
sam_grove 0:ec233f3b49d8 36 /**
sam_grove 0:ec233f3b49d8 37 * @class TLV320AIC1110
sam_grove 0:ec233f3b49d8 38 * @brief API abstraction for the TLV320AIC1110 audio CODEC
sam_grove 0:ec233f3b49d8 39 */
sam_grove 0:ec233f3b49d8 40 class TLV320AIC1110
sam_grove 0:ec233f3b49d8 41 {
sam_grove 0:ec233f3b49d8 42 private:
sam_grove 0:ec233f3b49d8 43 I2C *_i2c;
sam_grove 0:ec233f3b49d8 44
sam_grove 4:470f89e786f9 45 /**
sam_grove 4:470f89e786f9 46 * @enum TLV320AIC1110_REGISTERS
sam_grove 4:470f89e786f9 47 * @brief The device register map
sam_grove 4:470f89e786f9 48 */
sam_grove 2:e7c7c0177dd8 49 enum TLV320AIC1110_REGISTERS
sam_grove 2:e7c7c0177dd8 50 {
sam_grove 2:e7c7c0177dd8 51 POWER_CONTROL = 0, MODE_CONTROL, TXPGA, RXPGA, HI_DTMF, LO_DTMF, AUX
sam_grove 2:e7c7c0177dd8 52 };
sam_grove 4:470f89e786f9 53
sam_grove 4:470f89e786f9 54 /**
sam_grove 4:470f89e786f9 55 * @enum CHANNEL_T
sam_grove 4:470f89e786f9 56 * @brief List of channels that can be muted / unmuted
sam_grove 4:470f89e786f9 57 */
sam_grove 4:470f89e786f9 58 enum CHANNEL_T
sam_grove 4:470f89e786f9 59 {
sam_grove 4:470f89e786f9 60 RECEIVE = 0x04, TRANSMIT = 0x40, SIDETONE = 0x80
sam_grove 4:470f89e786f9 61 };
sam_grove 0:ec233f3b49d8 62
sam_grove 0:ec233f3b49d8 63 public:
sam_grove 4:470f89e786f9 64 /** Create the TLV320AIC1110 object
sam_grove 4:470f89e786f9 65 * @param i2c - A defined I2C object
sam_grove 4:470f89e786f9 66 */
sam_grove 0:ec233f3b49d8 67 TLV320AIC1110(I2C &i2c);
sam_grove 4:470f89e786f9 68
sam_grove 4:470f89e786f9 69 /** Destroy the TLV320AIC1110 object
sam_grove 4:470f89e786f9 70 */
sam_grove 0:ec233f3b49d8 71 ~TLV320AIC1110();
sam_grove 4:470f89e786f9 72
sam_grove 4:470f89e786f9 73 /** Print register values to the stdio stream
sam_grove 4:470f89e786f9 74 */
sam_grove 4:470f89e786f9 75 void regDump(void);
sam_grove 4:470f89e786f9 76
sam_grove 4:470f89e786f9 77 /** Initialize the register settings to basic operational settings
sam_grove 4:470f89e786f9 78 */
sam_grove 4:470f89e786f9 79 void init(void);
sam_grove 4:470f89e786f9 80
sam_grove 4:470f89e786f9 81 /** Direct write access to a device register
sam_grove 4:470f89e786f9 82 * @param reg - A register name from the register map enum
sam_grove 4:470f89e786f9 83 * @param value - The value to write to the specified register
sam_grove 4:470f89e786f9 84 */
sam_grove 4:470f89e786f9 85 void writeRegister(const TLV320AIC1110_REGISTERS reg, const uint8_t value);
sam_grove 4:470f89e786f9 86
sam_grove 4:470f89e786f9 87 /** Read the contents from a specific register
sam_grove 4:470f89e786f9 88 * @param reg - A register name from the register map enum
sam_grove 4:470f89e786f9 89 */
sam_grove 4:470f89e786f9 90 uint8_t readRegister(const uint8_t reg);
sam_grove 4:470f89e786f9 91
sam_grove 4:470f89e786f9 92 /** Mute an audio stream - bit mapped enum values so multiple can be "or'd" and passed
sam_grove 4:470f89e786f9 93 * @param ch - A channel name from the channel access enum
sam_grove 4:470f89e786f9 94 */
sam_grove 4:470f89e786f9 95 void mute(const CHANNEL_T ch);
sam_grove 4:470f89e786f9 96
sam_grove 4:470f89e786f9 97 /** Un-mute an audio stream - bit mapped enum values so multiple can be "or'd" and passed
sam_grove 4:470f89e786f9 98 * @param ch - A channel name from the channel access enum
sam_grove 4:470f89e786f9 99 */
sam_grove 4:470f89e786f9 100 void unmute(const CHANNEL_T ch);
sam_grove 4:470f89e786f9 101
sam_grove 4:470f89e786f9 102 /** Adjust the gain applied to the transmit audio stream
sam_grove 4:470f89e786f9 103 * @param gain - Adjustable from 20dB to 42dB in 2dB steps (passed as 20 ... 42)
sam_grove 4:470f89e786f9 104 */
sam_grove 4:470f89e786f9 105 uint32_t txGain(const uint8_t gain);
sam_grove 4:470f89e786f9 106
sam_grove 4:470f89e786f9 107 /** Adjust the local sidetone
sam_grove 4:470f89e786f9 108 * @param gain - Adjustable from -12dB to -24dB in 2dB steps (passed as -12 ... -24)
sam_grove 4:470f89e786f9 109 */
sam_grove 4:470f89e786f9 110 uint32_t sidetoneGain(const int8_t gain);
sam_grove 4:470f89e786f9 111
sam_grove 4:470f89e786f9 112 /** Adjust the gain applied to the receive audio stream
sam_grove 4:470f89e786f9 113 * @param gain - Adjustable from 6dB to -6dB in 1dB steps (passed as 6 ... -6)
sam_grove 4:470f89e786f9 114 */
sam_grove 4:470f89e786f9 115 uint32_t rxGain(const int8_t gain);
sam_grove 4:470f89e786f9 116
sam_grove 4:470f89e786f9 117 /** Adjust the volume of the EARxOP outputs that drive speakers or line outputs
sam_grove 4:470f89e786f9 118 * @param gain - Adjustable from 0dB to -18dB in 2dB steps (passed as 0 ... -18)
sam_grove 4:470f89e786f9 119 */
sam_grove 4:470f89e786f9 120 uint32_t rxVolume(const int8_t gain);
sam_grove 4:470f89e786f9 121
sam_grove 0:ec233f3b49d8 122 };
sam_grove 0:ec233f3b49d8 123
sam_grove 0:ec233f3b49d8 124
sam_grove 0:ec233f3b49d8 125 #endif
sam_grove 0:ec233f3b49d8 126