Device driver for TI TLV320AIC1110 voice band codec

Work in Progress

Files at this revision

API Documentation at this revision

Comitter:
sam_grove
Date:
Fri May 10 21:14:19 2013 +0000
Child:
1:4d559df5733e
Child:
2:e7c7c0177dd8
Commit message:
Initial commit. Basic functionality. Untested

Changed in this revision

TLV320AIC1110.cpp Show annotated file Show diff for this revision Revisions of this file
TLV320AIC1110.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TLV320AIC1110.cpp	Fri May 10 21:14:19 2013 +0000
@@ -0,0 +1,79 @@
+/**
+ * @file    TLV320AIC1110.cpp
+ * @brief   Device driver - TLV320AIC1110 CODEC
+ * @author  sam grove
+ * @version 1.0
+ * @see     http://www.ti.com/product/tlv320aic1110
+ *
+ * Copyright (c) 2013
+ *
+ * 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.
+ */
+ 
+#include "TLV320AIC1110.h"
+
+TLV320AIC1110::TLV320AIC1110(I2C &i2c)
+{
+    _i2c = &i2c;
+    _i2c->frequency(400000);
+    
+    return;
+}
+
+TLV320AIC1110::~TLV320AIC1110()
+{
+    return;
+}
+
+void TLV320AIC1110::init(void)
+{
+    writeRegister(0x00, 0x9B);
+    writeRegister(0x01, 0x00);
+    writeRegister(0x06, 0x81);
+    
+    return;
+}
+
+void TLV320AIC1110::writeRegister(const uint8_t reg, const uint8_t value)
+{
+    const uint8_t w_address = 0xE2;
+    uint8_t data[2] = {reg, value};
+    
+    if (0 != _i2c->write(w_address, (char *)data, 2))
+    {
+        // catch an error here
+    }
+    
+    return;
+}
+
+uint8_t TLV320AIC1110::readRegister(const uint8_t reg)
+{
+    const uint8_t w_address = 0xE2;
+    const uint8_t r_address = 0xE3;
+    uint8_t data[1] = {reg};
+    
+    _i2c->write(w_address, (char *)data, 1);
+    _i2c->start();
+    _i2c->write(r_address);
+    data[0] = _i2c->read(0);
+    _i2c->stop();
+    
+    return data[0];
+}
+
+
+
+
+
+    
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TLV320AIC1110.h	Fri May 10 21:14:19 2013 +0000
@@ -0,0 +1,56 @@
+/**
+ * @file    TLV320AIC1110.h
+ * @brief   Device driver - TLV320AIC1110 CODEC
+ * @author  sam grove
+ * @version 1.0
+ * @see     http://www.ti.com/product/tlv320aic1110
+ *
+ * Copyright (c) 2013
+ *
+ * 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 TLV320AIC1110_H
+#define TLV320AIC1110_H
+
+#include "mbed.h"
+
+/** Using the TI TLV320AIC1110 audio CODEC
+ *
+ * Example:
+ * @code
+
+ * @endcode
+ */
+
+/**
+ *  @class TLV320AIC1110
+ *  @brief API abstraction for the TLV320AIC1110 audio CODEC
+ */ 
+class TLV320AIC1110
+{
+private:
+    I2C     *_i2c;
+    
+    void writeRegister(const uint8_t reg, const uint8_t value);
+    uint8_t readRegister(const uint8_t reg);
+
+public:
+    TLV320AIC1110(I2C &i2c);
+    ~TLV320AIC1110();
+    void init(void);
+};
+
+
+#endif
+