Bela
Real-time, ultra-low-latency audio and sensor processing system for BeagleBone Black
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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 enableHpOut(bool enable);
56  int enableLineOut(bool enable);
57  int disable();
58  int reset(){ return 0; } // Not needed for audio codec on Bela cape
59 
60  int readI2C();
61  void setVerbose(bool isVerbose);
62 
63  I2c_Codec(int i2cBus, int I2cAddress, bool verbose = false);
64  ~I2c_Codec();
65 
66 private:
67  int configureDCRemovalIIR(); //called by startAudio()
68  int dacVolumeHalfDbs;
69  int adcVolumeHalfDbs;
70  int hpVolumeHalfDbs;
71  bool running;
72  bool verbose;
73  bool hpEnabled;
74 };
75 
76 
77 #endif /* I2CCODEC_H_ */
Definition: AudioCodec.h:4
Definition: I2c.h:23
Definition: I2c_Codec.h:23