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
Mcasp.h
1 #pragma once
2 #include <stdint.h>
3 #include <vector>
4 static const uint32_t MCASP_PIN_AFSX = 1 << 28;
5 static const uint32_t MCASP_PIN_AHCLKX = 1 << 27;
6 static const uint32_t MCASP_PIN_ACLKX = 1 << 26;
7 static const uint32_t MCASP_PIN_AMUTE = 1 << 25; // Also, 0 to 3 are XFR0 to XFR3
8 
10 {
11  uint32_t pdir;
12  uint32_t rmask;
13  uint32_t rfmt;
14  uint32_t afsrctl;
15  uint32_t aclkrctl;
16  uint32_t ahclkrctl;
17  uint32_t rtdm;
18  uint32_t xmask;
19  uint32_t xfmt;
20  uint32_t afsxctl;
21  uint32_t aclkxctl;
22  uint32_t ahclkxctl;
23  uint32_t xtdm;
24  uint32_t srctln;
25  uint32_t wfifoctl;
26  uint32_t rfifoctl;
27  // the below are not real registers, but it's data we pass to the PRU
28  uint32_t mcaspOutChannels;
29  uint32_t outSerializersDisabledSubSlots;
30 };
31 
33 {
34 public:
35  struct Parameters
36  {
37  unsigned int inChannels;
38  unsigned int outChannels;
39  std::vector<unsigned int> inSerializers;
40  std::vector<unsigned int> outSerializers;
41  unsigned int numSlots;
42  unsigned int slotSize;
43  unsigned int dataSize;
44  unsigned int bitDelay;
45  double auxClkIn;
46  double ahclkFreq;
47  bool ahclkIsInternal;
48  bool aclkIsInternal;
49  bool wclkIsInternal;
50  bool wclkIsWord;
51  bool wclkFalling;
52  bool externalSamplesRisingEdge;
53  };
54  typedef enum {
55  SrctlMode_DISABLED = 0,
56  SrctlMode_TX = 1,
57  SrctlMode_RX = 2,
58  } SrctlMode;
59  typedef enum {
60  SrctlDrive_TRISTATE = 0,
61  SrctlDrive_LOW = 2,
62  SrctlDrive_HIGH = 3,
63  } SrctlDrive;
64  double getValidAhclk(double desiredClock, unsigned int* outDiv = nullptr);
65  McaspConfig();
66  void print();
67  Parameters params;
68  McaspRegisters getRegisters();
69 private:
70  static uint32_t computeTdm(unsigned int numSlots);
71  static uint32_t computeFifoctl(unsigned int numSerializers);
72  int setFmt();
73  int setAfsctl();
74  int setAclkctl();
75  int setAhclkctl();
76  int setPdir();
77  int setSrctln(unsigned int n, McaspConfig::SrctlMode mode, McaspConfig::SrctlDrive drive);
78  int setChannels(unsigned int numChannels, std::vector<unsigned int>& serializers, bool input);
79 public:
80  McaspRegisters regs;
81 };
82 
83 namespace Mcasp {
84  void startAhclkx();
85  void stopAhclkx();
86 };
Definition: Mcasp.h:32
Definition: Mcasp.h:35
Definition: Mcasp.h:9