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_MultiTLVCodec.h
1 /*
2  * I2c_MultiTLVCodec.h
3  *
4  * Wrapper for multiple copies of the TLV320AIC310x
5  * codec on the same McASP TDM bus (but with different
6  * I2C addresses). Codec 0 provides the clock signals
7  * via its PLL and the other codecs are clocked to it.
8  *
9  * Created on: August 9, 2019
10  * Author: Andrew McPherson
11  */
12 
13 #pragma once
14 
15 #include <vector>
16 #include <memory>
17 #include "I2c_Codec.h"
18 
20 {
21 public:
22  class TdmConfig {
23  public:
24  TdmConfig(){};
25  unsigned int slotSize = 16;
26  unsigned int bitDelay = 0;
27  unsigned int firstSlot = 0;
28  };
29  int initCodec();
30  int startAudio(int shouldBeReady);
31  int stopAudio();
32  unsigned int getNumIns();
33  unsigned int getNumOuts();
34  float getSampleRate();
35 
36  int setInputGain(int channel, float newGain);
37  int setLineOutVolume(int channel, float gain);
38  int setHpVolume(int channel, float gain);
39  int disable();
40  int reset();
41  int setMode(std::string parameter);
42 
43  int numDetectedCodecs();
44 
45  void debugWriteRegister(int codecNum, int regNum, int value);
46  int debugReadRegister(int codecNum, int regNum);
47  McaspConfig& getMcaspConfig();
48 
50  I2c_MultiTLVCodec(const std::string& cfgString, TdmConfig tdmConfig = TdmConfig(), bool isVerbose = false);
52 
53 protected:
54  McaspConfig mcaspConfig;
55  std::shared_ptr<I2c_Codec> primaryCodec; // this will be the same as one of the elements of codecs
56 private:
57  std::vector<std::shared_ptr<I2c_Codec>> codecs;
58  std::vector<std::shared_ptr<I2c_Codec>> disabledCodecs;
59 
60  bool running;
61  bool verbose;
62 };
Definition: I2c_MultiTLVCodec.h:19
Definition: AudioCodec.h:29
Definition: Mcasp.h:32
Definition: I2c_MultiTLVCodec.h:22