i2s.h 8.8 KB

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