i2s.h 6.7 KB

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