1 //*****************************************************************************
2 //
3 // i2s.h - Prototypes and macros for the I2S controller.
4 //
5 // Copyright (c) 2008-2011 Texas Instruments Incorporated.  All rights reserved.
6 // Software License Agreement
7 //
8 // Texas Instruments (TI) is supplying this software for use solely and
9 // exclusively on TI's microcontroller products. The software is owned by
10 // TI and/or its suppliers, and is protected under applicable copyright
11 // laws. You may not combine this software with "viral" open-source
12 // software in order to form a larger program.
13 //
14 // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
15 // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
16 // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17 // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
18 // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
19 // DAMAGES, FOR ANY REASON WHATSOEVER.
20 //
21 // This is part of revision 8264 of the Stellaris Peripheral Driver Library.
22 //
23 //*****************************************************************************
24 
25 #ifndef __I2S_H__
26 #define __I2S_H__
27 
28 //*****************************************************************************
29 //
30 // If building with a C++ compiler, make all of the definitions in this header
31 // have a C binding.
32 //
33 //*****************************************************************************
34 #ifdef __cplusplus
35 extern "C"
36 {
37 #endif
38 
39 //*****************************************************************************
40 //
41 // Values that can be passed to I2STxConfigSet() and I2SRxConfigSet()
42 //
43 //*****************************************************************************
44 #define I2S_CONFIG_FORMAT_MASK  0x3C000000  //  JST,  DLY,  SCP,  LRP
45 #define I2S_CONFIG_FORMAT_I2S   0x14000000  // !JST,  DLY, !SCP,  LRP
46 #define I2S_CONFIG_FORMAT_LEFT_JUST \
47                                 0x00000000  // !JST, !DLY, !SCP, !LRP
48 #define I2S_CONFIG_FORMAT_RIGHT_JUST \
49                                 0x20000000  //  JST, !DLY, !SCP, !LRP
50 
51 #define I2S_CONFIG_SCLK_INVERT  0x08000000
52 
53 #define I2S_CONFIG_MODE_MASK    0x03000000
54 #define I2S_CONFIG_MODE_DUAL    0x00000000
55 #define I2S_CONFIG_MODE_COMPACT_16 \
56                                 0x01000000
57 #define I2S_CONFIG_MODE_COMPACT_8 \
58                                 0x03000000
59 #define I2S_CONFIG_MODE_MONO    0x02000000
60 
61 #define I2S_CONFIG_EMPTY_MASK   0x00800000
62 #define I2S_CONFIG_EMPTY_ZERO   0x00000000
63 #define I2S_CONFIG_EMPTY_REPEAT 0x00800000
64 
65 #define I2S_CONFIG_CLK_MASK     0x00400000
66 #define I2S_CONFIG_CLK_MASTER   0x00400000
67 #define I2S_CONFIG_CLK_SLAVE    0x00000000
68 
69 #define I2S_CONFIG_SAMPLE_SIZE_MASK \
70                                 0x0000FC00
71 #define I2S_CONFIG_SAMPLE_SIZE_32 \
72                                 0x00007C00
73 #define I2S_CONFIG_SAMPLE_SIZE_24 \
74                                 0x00005C00
75 #define I2S_CONFIG_SAMPLE_SIZE_20 \
76                                 0x00004C00
77 #define I2S_CONFIG_SAMPLE_SIZE_16 \
78                                 0x00003C00
79 #define I2S_CONFIG_SAMPLE_SIZE_8 \
80                                 0x00001C00
81 
82 #define I2S_CONFIG_WIRE_SIZE_MASK \
83                                 0x000003F0
84 #define I2S_CONFIG_WIRE_SIZE_32 0x000001F0
85 #define I2S_CONFIG_WIRE_SIZE_24 0x00000170
86 #define I2S_CONFIG_WIRE_SIZE_20 0x00000130
87 #define I2S_CONFIG_WIRE_SIZE_16 0x000000F0
88 #define I2S_CONFIG_WIRE_SIZE_8  0x00000070
89 
90 //*****************************************************************************
91 //
92 // Values that can be passed to I2SMasterClockSelect()
93 //
94 //*****************************************************************************
95 #define I2S_TX_MCLK_EXT         0x00000010
96 #define I2S_TX_MCLK_INT         0x00000000
97 #define I2S_RX_MCLK_EXT         0x00000020
98 #define I2S_RX_MCLK_INT         0x00000000
99 
100 //*****************************************************************************
101 //
102 // Values that can be passed to I2SIntEnable(), I2SIntDisable(), and
103 // I2SIntClear()
104 //
105 //*****************************************************************************
106 #define I2S_INT_RXERR           0x00000020
107 #define I2S_INT_RXREQ           0x00000010
108 #define I2S_INT_TXERR           0x00000002
109 #define I2S_INT_TXREQ           0x00000001
110 
111 //*****************************************************************************
112 //
113 // API Function prototypes
114 //
115 //*****************************************************************************
116 extern void I2STxEnable(unsigned long ulBase);
117 extern void I2STxDisable(unsigned long ulBase);
118 extern void I2STxDataPut(unsigned long ulBase, unsigned long ulData);
119 extern long I2STxDataPutNonBlocking(unsigned long ulBase,
120                                     unsigned long ulData);
121 extern void I2STxConfigSet(unsigned long ulBase, unsigned long ulConfig);
122 extern void I2STxFIFOLimitSet(unsigned long ulBase, unsigned long ulLevel);
123 extern unsigned long I2STxFIFOLimitGet(unsigned long ulBase);
124 extern unsigned long I2STxFIFOLevelGet(unsigned long ulBase);
125 extern void I2SRxEnable(unsigned long ulBase);
126 extern void I2SRxDisable(unsigned long ulBase);
127 extern void I2SRxDataGet(unsigned long ulBase, unsigned long *pulData);
128 extern long I2SRxDataGetNonBlocking(unsigned long ulBase,
129                                     unsigned long *pulData);
130 extern void I2SRxConfigSet(unsigned long ulBase, unsigned long ulConfig);
131 extern void I2SRxFIFOLimitSet(unsigned long ulBase, unsigned long ulLevel);
132 extern unsigned long I2SRxFIFOLimitGet(unsigned long ulBase);
133 extern unsigned long I2SRxFIFOLevelGet(unsigned long ulBase);
134 extern void I2STxRxEnable(unsigned long ulBase);
135 extern void I2STxRxDisable(unsigned long ulBase);
136 extern void I2STxRxConfigSet(unsigned long ulBase, unsigned long ulConfig);
137 extern void I2SMasterClockSelect(unsigned long ulBase, unsigned long ulMClock);
138 extern void I2SIntEnable(unsigned long ulBase, unsigned long ulIntFlags);
139 extern void I2SIntDisable(unsigned long ulBase, unsigned long ulIntFlags);
140 extern unsigned long I2SIntStatus(unsigned long ulBase, tBoolean bMasked);
141 extern void I2SIntClear(unsigned long ulBase, unsigned long ulIntFlags);
142 extern void I2SIntRegister(unsigned long ulBase, void (*pfnHandler)(void));
143 extern void I2SIntUnregister(unsigned long ulBase);
144 
145 //*****************************************************************************
146 //
147 // Mark the end of the C bindings section for C++ compilers.
148 //
149 //*****************************************************************************
150 #ifdef __cplusplus
151 }
152 #endif
153 
154 #endif //  __I2S_H__
155