1 //*****************************************************************************
2 //
3 // i2s.h - Prototypes and macros for the I2S controller.
4 //
5 // Copyright (c) 2008-2012 Texas Instruments Incorporated.  All rights reserved.
6 // Software License Agreement
7 //
8 //   Redistribution and use in source and binary forms, with or without
9 //   modification, are permitted provided that the following conditions
10 //   are met:
11 //
12 //   Redistributions of source code must retain the above copyright
13 //   notice, this list of conditions and the following disclaimer.
14 //
15 //   Redistributions in binary form must reproduce the above copyright
16 //   notice, this list of conditions and the following disclaimer in the
17 //   documentation and/or other materials provided with the
18 //   distribution.
19 //
20 //   Neither the name of Texas Instruments Incorporated nor the names of
21 //   its contributors may be used to endorse or promote products derived
22 //   from this software without specific prior written permission.
23 //
24 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 //
36 // This is part of revision 9453 of the Stellaris Peripheral Driver Library.
37 //
38 //*****************************************************************************
39 
40 #ifndef __I2S_H__
41 #define __I2S_H__
42 
43 //*****************************************************************************
44 //
45 // If building with a C++ compiler, make all of the definitions in this header
46 // have a C binding.
47 //
48 //*****************************************************************************
49 #ifdef __cplusplus
50 extern "C"
51 {
52 #endif
53 
54 //*****************************************************************************
55 //
56 // Values that can be passed to I2STxConfigSet() and I2SRxConfigSet()
57 //
58 //*****************************************************************************
59 #define I2S_CONFIG_FORMAT_MASK  0x3C000000  //  JST,  DLY,  SCP,  LRP
60 #define I2S_CONFIG_FORMAT_I2S   0x14000000  // !JST,  DLY, !SCP,  LRP
61 #define I2S_CONFIG_FORMAT_LEFT_JUST \
62                                 0x00000000  // !JST, !DLY, !SCP, !LRP
63 #define I2S_CONFIG_FORMAT_RIGHT_JUST \
64                                 0x20000000  //  JST, !DLY, !SCP, !LRP
65 
66 #define I2S_CONFIG_SCLK_INVERT  0x08000000
67 
68 #define I2S_CONFIG_MODE_MASK    0x03000000
69 #define I2S_CONFIG_MODE_DUAL    0x00000000
70 #define I2S_CONFIG_MODE_COMPACT_16 \
71                                 0x01000000
72 #define I2S_CONFIG_MODE_COMPACT_8 \
73                                 0x03000000
74 #define I2S_CONFIG_MODE_MONO    0x02000000
75 
76 #define I2S_CONFIG_EMPTY_MASK   0x00800000
77 #define I2S_CONFIG_EMPTY_ZERO   0x00000000
78 #define I2S_CONFIG_EMPTY_REPEAT 0x00800000
79 
80 #define I2S_CONFIG_CLK_MASK     0x00400000
81 #define I2S_CONFIG_CLK_MASTER   0x00400000
82 #define I2S_CONFIG_CLK_SLAVE    0x00000000
83 
84 #define I2S_CONFIG_SAMPLE_SIZE_MASK \
85                                 0x0000FC00
86 #define I2S_CONFIG_SAMPLE_SIZE_32 \
87                                 0x00007C00
88 #define I2S_CONFIG_SAMPLE_SIZE_24 \
89                                 0x00005C00
90 #define I2S_CONFIG_SAMPLE_SIZE_20 \
91                                 0x00004C00
92 #define I2S_CONFIG_SAMPLE_SIZE_16 \
93                                 0x00003C00
94 #define I2S_CONFIG_SAMPLE_SIZE_8 \
95                                 0x00001C00
96 
97 #define I2S_CONFIG_WIRE_SIZE_MASK \
98                                 0x000003F0
99 #define I2S_CONFIG_WIRE_SIZE_32 0x000001F0
100 #define I2S_CONFIG_WIRE_SIZE_24 0x00000170
101 #define I2S_CONFIG_WIRE_SIZE_20 0x00000130
102 #define I2S_CONFIG_WIRE_SIZE_16 0x000000F0
103 #define I2S_CONFIG_WIRE_SIZE_8  0x00000070
104 
105 //*****************************************************************************
106 //
107 // Values that can be passed to I2SMasterClockSelect()
108 //
109 //*****************************************************************************
110 #define I2S_TX_MCLK_EXT         0x00000010
111 #define I2S_TX_MCLK_INT         0x00000000
112 #define I2S_RX_MCLK_EXT         0x00000020
113 #define I2S_RX_MCLK_INT         0x00000000
114 
115 //*****************************************************************************
116 //
117 // Values that can be passed to I2SIntEnable(), I2SIntDisable(), and
118 // I2SIntClear()
119 //
120 //*****************************************************************************
121 #define I2S_INT_RXERR           0x00000020
122 #define I2S_INT_RXREQ           0x00000010
123 #define I2S_INT_TXERR           0x00000002
124 #define I2S_INT_TXREQ           0x00000001
125 
126 //*****************************************************************************
127 //
128 // API Function prototypes
129 //
130 //*****************************************************************************
131 extern void I2STxEnable(unsigned long ulBase);
132 extern void I2STxDisable(unsigned long ulBase);
133 extern void I2STxDataPut(unsigned long ulBase, unsigned long ulData);
134 extern long I2STxDataPutNonBlocking(unsigned long ulBase,
135                                     unsigned long ulData);
136 extern void I2STxConfigSet(unsigned long ulBase, unsigned long ulConfig);
137 extern void I2STxFIFOLimitSet(unsigned long ulBase, unsigned long ulLevel);
138 extern unsigned long I2STxFIFOLimitGet(unsigned long ulBase);
139 extern unsigned long I2STxFIFOLevelGet(unsigned long ulBase);
140 extern void I2SRxEnable(unsigned long ulBase);
141 extern void I2SRxDisable(unsigned long ulBase);
142 extern void I2SRxDataGet(unsigned long ulBase, unsigned long *pulData);
143 extern long I2SRxDataGetNonBlocking(unsigned long ulBase,
144                                     unsigned long *pulData);
145 extern void I2SRxConfigSet(unsigned long ulBase, unsigned long ulConfig);
146 extern void I2SRxFIFOLimitSet(unsigned long ulBase, unsigned long ulLevel);
147 extern unsigned long I2SRxFIFOLimitGet(unsigned long ulBase);
148 extern unsigned long I2SRxFIFOLevelGet(unsigned long ulBase);
149 extern void I2STxRxEnable(unsigned long ulBase);
150 extern void I2STxRxDisable(unsigned long ulBase);
151 extern void I2STxRxConfigSet(unsigned long ulBase, unsigned long ulConfig);
152 extern void I2SMasterClockSelect(unsigned long ulBase, unsigned long ulMClock);
153 extern void I2SIntEnable(unsigned long ulBase, unsigned long ulIntFlags);
154 extern void I2SIntDisable(unsigned long ulBase, unsigned long ulIntFlags);
155 extern unsigned long I2SIntStatus(unsigned long ulBase, tBoolean bMasked);
156 extern void I2SIntClear(unsigned long ulBase, unsigned long ulIntFlags);
157 extern void I2SIntRegister(unsigned long ulBase, void (*pfnHandler)(void));
158 extern void I2SIntUnregister(unsigned long ulBase);
159 
160 //*****************************************************************************
161 //
162 // Mark the end of the C bindings section for C++ compilers.
163 //
164 //*****************************************************************************
165 #ifdef __cplusplus
166 }
167 #endif
168 
169 #endif //  __I2S_H__
170