Device driver for TI TLV320AIC1110 voice band codec
Work in Progress
Revision 3:4592d862ef88, committed 2013-05-15
- Comitter:
- sam_grove
- Date:
- Wed May 15 21:12:22 2013 +0000
- Parent:
- 1:4d559df5733e
- Parent:
- 2:e7c7c0177dd8
- Child:
- 4:470f89e786f9
- Commit message:
- Merged.
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 Wed May 15 21:07:10 2013 +0000 +++ b/TLV320AIC1110.cpp Wed May 15 21:12:22 2013 +0000 @@ -26,7 +26,7 @@ TLV320AIC1110::TLV320AIC1110(I2C &i2c) { _i2c = &i2c; - _i2c->frequency(100000); + _i2c->frequency(400000); return; } @@ -36,16 +36,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::regDump(void) +void TLV320AIC1110::regDump(void) const { for(int i=0; i<7; i++) { @@ -55,7 +55,7 @@ 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}; @@ -66,31 +66,29 @@ ERROR("write failed\n"); } __enable_irq(); - -// _i2c->start(); -// _i2c->write(w_address); -// _i2c->write(reg); -// _i2c->write(value); -// _i2c->stop(); 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}; __disable_irq(); - _i2c->start(); - _i2c->write(w_address); - _i2c->write(reg); - _i2c->stop(); - _i2c->start(); - _i2c->write(r_address); - data[0] = _i2c->read(1); - _i2c->stop(); + _i2c->write(w_address, (char *)data, 1, 1); + _i2c->read (r_address, data, 1); __enable_irq(); + +// _i2c->start(); +// _i2c->write(w_address); +// _i2c->write(reg); +// _i2c->stop(); +// _i2c->start(); +// _i2c->write(r_address); +// data[0] = _i2c->read(1); +// _i2c->stop(); + return data[0]; }
--- a/TLV320AIC1110.h Wed May 15 21:07:10 2013 +0000 +++ b/TLV320AIC1110.h Wed May 15 21:12:22 2013 +0000 @@ -42,14 +42,18 @@ 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 regDump(void); + void regDump(void) const ; + void init(void) const ; + void writeRegister(const TLV320AIC1110_REGISTERS reg, const uint8_t value) const ; + uint8_t readRegister(const uint8_t reg) const ; };