Device driver for TI TLV320AIC1110 voice band codec

Work in Progress

Files at this revision

API Documentation at this revision

Comitter:
sam_grove
Date:
Wed May 15 21:07:55 2013 +0000
Parent:
0:ec233f3b49d8
Child:
3:4592d862ef88
Commit message:
Some update to read and the exposure of members

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
--- a/TLV320AIC1110.cpp	Fri May 10 21:14:19 2013 +0000
+++ b/TLV320AIC1110.cpp	Wed May 15 21:07:55 2013 +0000
@@ -35,16 +35,16 @@
     return;
 }
 
-void TLV320AIC1110::init(void)
+void TLV320AIC1110::init(void) const
 {
-    writeRegister(0x00, 0x9B);
-    writeRegister(0x01, 0x00);
-    writeRegister(0x06, 0x81);
+    writeRegister(POWER_CONTROL, 0x9B);
+    writeRegister(MODE_CONTROL, 0x00);
+    writeRegister(AUX, 0x81);
     
     return;
 }
 
-void TLV320AIC1110::writeRegister(const uint8_t reg, const uint8_t value)
+void TLV320AIC1110::writeRegister(const TLV320AIC1110_REGISTERS reg, const uint8_t value) const
 {
     const uint8_t w_address = 0xE2;
     uint8_t data[2] = {reg, value};
@@ -57,17 +57,18 @@
     return;
 }
 
-uint8_t TLV320AIC1110::readRegister(const uint8_t reg)
+uint8_t TLV320AIC1110::readRegister(const uint8_t reg) const
 {
     const uint8_t w_address = 0xE2;
     const uint8_t r_address = 0xE3;
-    uint8_t data[1] = {reg};
+    char data[1] = {reg};
     
-    _i2c->write(w_address, (char *)data, 1);
-    _i2c->start();
-    _i2c->write(r_address);
-    data[0] = _i2c->read(0);
-    _i2c->stop();
+    _i2c->write(w_address, (char *)data, 1, 1);
+    _i2c->read (r_address, data, 1);
+//    _i2c->start();
+//    _i2c->write(r_address);
+//    data[0] = _i2c->read(0);
+//    _i2c->stop();
     
     return data[0];
 }
--- a/TLV320AIC1110.h	Fri May 10 21:14:19 2013 +0000
+++ b/TLV320AIC1110.h	Wed May 15 21:07:55 2013 +0000
@@ -42,13 +42,17 @@
 private:
     I2C     *_i2c;
     
-    void writeRegister(const uint8_t reg, const uint8_t value);
-    uint8_t readRegister(const uint8_t reg);
+    enum TLV320AIC1110_REGISTERS
+    {
+        POWER_CONTROL = 0, MODE_CONTROL, TXPGA, RXPGA, HI_DTMF, LO_DTMF, AUX
+    };
 
 public:
     TLV320AIC1110(I2C &i2c);
     ~TLV320AIC1110();
-    void init(void);
+    void init(void) const ;
+    void writeRegister(const TLV320AIC1110_REGISTERS reg, const uint8_t value) const ;
+    uint8_t readRegister(const uint8_t reg) const ;
 };