1 /*
2  *  Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/
3  *
4  *  Redistribution and use in source and binary forms, with or without
5  *  modification, are permitted provided that the following conditions
6  *  are met:
7  *
8  *    Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  *
11  *    Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the
14  *    distribution.
15  *
16  *    Neither the name of Texas Instruments Incorporated nor the names of
17  *    its contributors may be used to endorse or promote products derived
18  *    from this software without specific prior written permission.
19  *
20  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
33 //*****************************************************************************
34 //
35 //  i2s.h
36 //
37 //  Defines and Macros for the I2S.
38 //
39 //*****************************************************************************
40 
41 #ifndef __I2S_H__
42 #define __I2S_H__
43 
44 //*****************************************************************************
45 //
46 // If building with a C++ compiler, make all of the definitions in this header
47 // have a C binding.
48 //
49 //*****************************************************************************
50 #ifdef __cplusplus
51 extern "C"
52 {
53 #endif
54 
55 //*****************************************************************************
56 //
57 // I2S DMA ports.
58 //
59 //*****************************************************************************
60 #define I2S_TX_DMA_PORT      0x4401E200
61 #define I2S_RX_DMA_PORT      0x4401E280
62 
63 //*****************************************************************************
64 //
65 // Values that can be passed to I2SConfigSetExpClk() as the ulConfig parameter.
66 //
67 //*****************************************************************************
68 #define I2S_SLOT_SIZE_8       0x00300032
69 #define I2S_SLOT_SIZE_16      0x00700074
70 #define I2S_SLOT_SIZE_24      0x00B000B6
71 
72 
73 #define I2S_PORT_CPU          0x00080008
74 #define I2S_PORT_DMA          0x00000000
75 
76 #define I2S_MODE_MASTER       0x00000000
77 #define I2S_MODE_SLAVE        0x00008000
78 
79 //*****************************************************************************
80 //
81 // Values that can be passed as ulDataLine parameter.
82 //
83 //*****************************************************************************
84 #define I2S_DATA_LINE_0       0x00000001
85 #define I2S_DATA_LINE_1       0x00000002
86 
87 //*****************************************************************************
88 //
89 // Values that can be passed to I2SSerializerConfig() as the ulSerMode
90 // parameter.
91 //
92 //*****************************************************************************
93 #define I2S_SER_MODE_TX       0x00000001
94 #define I2S_SER_MODE_RX       0x00000002
95 #define I2S_SER_MODE_DISABLE  0x00000000
96 
97 //*****************************************************************************
98 //
99 // Values that can be passed to I2SSerializerConfig() as the ulInActState
100 // parameter.
101 //
102 //*****************************************************************************
103 #define I2S_INACT_TRI_STATE   0x00000000
104 #define I2S_INACT_LOW_LEVEL   0x00000008
105 #define I2S_INACT_HIGH_LEVEL  0x0000000C
106 
107 //*****************************************************************************
108 //
109 // Values that can be passed to I2SIntEnable() and I2SIntDisable() as the
110 // ulIntFlags parameter.
111 //
112 //*****************************************************************************
113 #define I2S_INT_XUNDRN	      0x00000001
114 #define I2S_INT_XSYNCERR      0x00000002
115 #define I2S_INT_XLAST         0x00000010
116 #define I2S_INT_XDATA         0x00000020
117 #define I2S_INT_XSTAFRM       0x00000080
118 #define I2S_INT_XDMA	      0x80000000
119 #define I2S_INT_ROVRN         0x00010000
120 #define I2S_INT_RSYNCERR      0x00020000
121 #define I2S_INT_RLAST         0x00100000
122 #define I2S_INT_RDATA         0x00200000
123 #define I2S_INT_RSTAFRM       0x00800000
124 #define I2S_INT_RDMA          0x40000000
125 
126 
127 //*****************************************************************************
128 //
129 // Values that can be passed to I2SRxActiveSlotSet() and I2STxActiveSlotSet
130 //
131 //*****************************************************************************
132 #define I2S_ACT_SLOT_EVEN     0x00000001
133 #define I2S_ACT_SLOT_ODD      0x00000002
134 
135 //*****************************************************************************
136 //
137 // Values that can be passed to I2SIntClear() as the
138 // ulIntFlags parameter and returned from I2SIntStatus().
139 //
140 //*****************************************************************************
141 #define I2S_STS_XERR          0x00000100
142 #define I2S_STS_XDMAERR	      0x00000080
143 #define I2S_STS_XSTAFRM	      0x00000040
144 #define I2S_STS_XDATA	      0x00000020
145 #define I2S_STS_XLAST	      0x00000010
146 #define I2S_STS_XSYNCERR      0x00000002
147 #define I2S_STS_XUNDRN	      0x00000001
148 #define I2S_STS_XDMA	      0x80000000
149 #define I2S_STS_RERR          0x01000000
150 #define I2S_STS_RDMAERR       0x00800000
151 #define I2S_STS_RSTAFRM       0x00400000
152 #define I2S_STS_RDATA         0x00200000
153 #define I2S_STS_RLAST         0x00100000
154 #define I2S_STS_RSYNCERR      0x00020000
155 #define I2S_STS_ROVERN	      0x00010000
156 #define I2S_STS_RDMA          0x40000000
157 
158 //*****************************************************************************
159 //
160 // Values that can be passed to I2SEnable() as the ulMode parameter.
161 //
162 //*****************************************************************************
163 #define I2S_MODE_TX_ONLY      0x00000001
164 #define I2S_MODE_TX_RX_SYNC   0x00000003
165 
166 
167 //*****************************************************************************
168 //
169 // API Function prototypes
170 //
171 //*****************************************************************************
172 extern void I2SEnable(unsigned long ulBase, unsigned long ulMode);
173 extern void I2SDisable(unsigned long ulBase);
174 
175 extern void I2SDataPut(unsigned long ulBase, unsigned long ulDataLine,
176                 unsigned long ulData);
177 extern long I2SDataPutNonBlocking(unsigned long ulBase,
178                                unsigned long ulDataLine, unsigned long ulData);
179 
180 extern void I2SDataGet(unsigned long ulBase, unsigned long ulDataLine,
181                 unsigned long *pulData);
182 extern long I2SDataGetNonBlocking(unsigned long ulBase,
183                 unsigned long ulDataLine, unsigned long *pulData);
184 
185 extern void I2SConfigSetExpClk(unsigned long ulBase, unsigned long ulI2SClk,
186                                unsigned long ulBitClk, unsigned long ulConfig);
187 
188 extern void I2STxFIFOEnable(unsigned long ulBase, unsigned long ulTxLevel,
189                      unsigned long ulWordsPerTransfer);
190 extern void I2STxFIFODisable(unsigned long ulBase);
191 extern void I2SRxFIFOEnable(unsigned long ulBase, unsigned long ulRxLevel,
192                      unsigned long ulWordsPerTransfer);
193 extern void I2SRxFIFODisable(unsigned long ulBase);
194 extern unsigned long I2STxFIFOStatusGet(unsigned long ulBase);
195 extern unsigned long I2SRxFIFOStatusGet(unsigned long ulBase);
196 
197 extern void I2SSerializerConfig(unsigned long ulBase, unsigned long ulDataLine,
198                          unsigned long ulSerMode, unsigned long ulInActState);
199 
200 extern void I2SIntEnable(unsigned long ulBase, unsigned long ulIntFlags);
201 extern void I2SIntDisable(unsigned long ulBase, unsigned long ulIntFlags);
202 extern unsigned long I2SIntStatus(unsigned long ulBase);
203 extern void I2SIntClear(unsigned long ulBase, unsigned long ulIntFlags);
204 extern void I2SIntRegister(unsigned long ulBase, void (*pfnHandler)(void));
205 extern void I2SIntUnregister(unsigned long ulBase);
206 extern void I2STxActiveSlotSet(unsigned long ulBase, unsigned long ulActSlot);
207 extern void I2SRxActiveSlotSet(unsigned long ulBase, unsigned long ulActSlot);
208 
209 //*****************************************************************************
210 //
211 // Mark the end of the C bindings section for C++ compilers.
212 //
213 //*****************************************************************************
214 #ifdef __cplusplus
215 }
216 #endif
217 
218 #endif //__I2S_H__
219 
220