Bela
Real-time, ultra-low-latency audio and sensor processing system for BeagleBone Black
 All Classes Files Functions Variables Typedefs Macros Groups
I2c_Codec.h
1 /*
2  * I2c_Codec.h
3  *
4  * Handle writing the registers to the TLV320AIC310x
5  * series audio codecs, used on the BeagleBone Audio Cape.
6  * This code is designed to bypass the ALSA driver and
7  * configure the codec directly in a sensible way. It
8  * is complemented by code running on the PRU which uses
9  * the McASP serial port to transfer audio data.
10  *
11  * Created on: May 25, 2014
12  * Author: Andrew McPherson
13  */
14 
15 
16 #ifndef I2CCODEC_H_
17 #define I2CCODEC_H_
18 
19 #include "AudioCodec.h"
20 #include "I2c.h"
21 
22 
23 class I2c_Codec : public I2c, public AudioCodec
24 {
25  short unsigned int pllJ;
26  short unsigned int pllD;
27  short unsigned int pllP;
28  short unsigned int pllR;
29 public:
30  int writeRegister(unsigned int reg, unsigned int value);
31 
32  int initCodec();
33  int startAudio(int dual_rate);
34  int stopAudio();
35 
36  int setPllJ(short unsigned int j);
37  int setPllD(unsigned int d);
38  int setPllP(short unsigned int p);
39  int setPllR(unsigned int r);
40  int setPllK(float k);
41  int setAudioSamplingRate(float newSamplingRate);
42  short unsigned int getPllJ();
43  unsigned int getPllD();
44  unsigned int getPllP();
45  unsigned int getPllR();
46  float getPllK();
47  float getAudioSamplingRate();
48  int setPga(float newGain, unsigned short int channel);
49  int setDACVolume(int halfDbSteps);
50  int writeDACVolumeRegisters(bool mute);
51  int setADCVolume(int halfDbSteps);
52  int writeADCVolumeRegisters(bool mute);
53  int setHPVolume(int halfDbSteps);
54  int writeHPVolumeRegisters();
55  int disable();
56  int reset(){ return 0; } // Not needed for audio codec on Bela cape
57 
58  int readI2C();
59  void setVerbose(bool isVerbose);
60 
61  I2c_Codec(int i2cBus, int I2cAddress, bool verbose = false);
62  ~I2c_Codec();
63 
64 private:
65  int configureDCRemovalIIR(); //called by startAudio()
66  int dacVolumeHalfDbs;
67  int adcVolumeHalfDbs;
68  int hpVolumeHalfDbs;
69  bool running;
70  bool verbose;
71 };
72 
73 
74 #endif /* I2CCODEC_H_ */
Definition: AudioCodec.h:4
Definition: I2c.h:36
Definition: I2c_Codec.h:23