hw_i2c.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. //###########################################################################
  2. //
  3. // FILE: hw_i2c.h
  4. //
  5. // TITLE: Definitions for the C28x I2C registers.
  6. //
  7. //###########################################################################
  8. // $TI Release: F2837xD Support Library v3.05.00.00 $
  9. // $Release Date: Tue Jun 26 03:15:23 CDT 2018 $
  10. // $Copyright:
  11. // Copyright (C) 2013-2018 Texas Instruments Incorporated - http://www.ti.com/
  12. //
  13. // Redistribution and use in source and binary forms, with or without
  14. // modification, are permitted provided that the following conditions
  15. // are met:
  16. //
  17. // Redistributions of source code must retain the above copyright
  18. // notice, this list of conditions and the following disclaimer.
  19. //
  20. // Redistributions in binary form must reproduce the above copyright
  21. // notice, this list of conditions and the following disclaimer in the
  22. // documentation and/or other materials provided with the
  23. // distribution.
  24. //
  25. // Neither the name of Texas Instruments Incorporated nor the names of
  26. // its contributors may be used to endorse or promote products derived
  27. // from this software without specific prior written permission.
  28. //
  29. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  30. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  31. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  32. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  33. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  34. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  35. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  36. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  37. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  38. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  39. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  40. // $
  41. //###########################################################################
  42. #ifndef __HW_I2C_H__
  43. #define __HW_I2C_H__
  44. //*****************************************************************************
  45. //
  46. // The following are defines for the I2C register offsets
  47. //
  48. //*****************************************************************************
  49. #define I2C_O_OAR 0x0 // I2C Own address
  50. #define I2C_O_IER 0x1 // I2C Interrupt Enable
  51. #define I2C_O_STR 0x2 // I2C Status
  52. #define I2C_O_CLKL 0x3 // I2C Clock low-time divider
  53. #define I2C_O_CLKH 0x4 // I2C Clock high-time divider
  54. #define I2C_O_CNT 0x5 // I2C Data count
  55. #define I2C_O_DRR 0x6 // I2C Data receive
  56. #define I2C_O_SAR 0x7 // I2C Slave address
  57. #define I2C_O_DXR 0x8 // I2C Data Transmit
  58. #define I2C_O_MDR 0x9 // I2C Mode
  59. #define I2C_O_ISRC 0xA // I2C Interrupt Source
  60. #define I2C_O_EMDR 0xB // I2C Extended Mode
  61. #define I2C_O_PSC 0xC // I2C Prescaler
  62. #define I2C_O_FFTX 0x20 // I2C FIFO Transmit
  63. #define I2C_O_FFRX 0x21 // I2C FIFO Receive
  64. //*****************************************************************************
  65. //
  66. // The following are defines for the bit fields in the I2COAR register
  67. //
  68. //*****************************************************************************
  69. #define I2C_OAR_OAR_S 0
  70. #define I2C_OAR_OAR_M 0x3FF // I2C Own address
  71. //*****************************************************************************
  72. //
  73. // The following are defines for the bit fields in the I2CIER register
  74. //
  75. //*****************************************************************************
  76. #define I2C_IER_ARBL 0x1 // Arbitration-lost interrupt
  77. // enable
  78. #define I2C_IER_NACK 0x2 // No-acknowledgment interrupt
  79. // enable
  80. #define I2C_IER_ARDY 0x4 // Register-access-ready interrupt
  81. // enable
  82. #define I2C_IER_RRDY 0x8 // Receive-data-ready interrupt
  83. // enable
  84. #define I2C_IER_XRDY 0x10 // Transmit-data-ready interrupt
  85. // enable
  86. #define I2C_IER_SCD 0x20 // Stop condition detected
  87. // interrupt enable
  88. #define I2C_IER_AAS 0x40 // Addressed as slave interrupt
  89. // enable
  90. //*****************************************************************************
  91. //
  92. // The following are defines for the bit fields in the I2CSTR register
  93. //
  94. //*****************************************************************************
  95. #define I2C_STR_ARBL 0x1 // Arbitration-lost interrupt flag
  96. // bit
  97. #define I2C_STR_NACK 0x2 // No-acknowledgment interrupt
  98. // flag bit.
  99. #define I2C_STR_ARDY 0x4 // Register-access-ready interrupt
  100. // flag bit
  101. #define I2C_STR_RRDY 0x8 // Receive-data-ready interrupt
  102. // flag bit.
  103. #define I2C_STR_XRDY 0x10 // Transmit-data-ready interrupt
  104. // flag bit.
  105. #define I2C_STR_SCD 0x20 // Stop condition detected bit.
  106. #define I2C_STR_AD0 0x100 // Address 0 bits
  107. #define I2C_STR_AAS 0x200 // Addressed-as-slave bit
  108. #define I2C_STR_XSMT 0x400 // Transmit shift register empty
  109. // bit.
  110. #define I2C_STR_RSFULL 0x800 // Receive shift register full
  111. // bit.
  112. #define I2C_STR_BB 0x1000 // Bus busy bit.
  113. #define I2C_STR_NACKSNT 0x2000 // NACK sent bit.
  114. #define I2C_STR_SDIR 0x4000 // Slave direction bit
  115. //*****************************************************************************
  116. //
  117. // The following are defines for the bit fields in the I2CCLKL register
  118. //
  119. //*****************************************************************************
  120. #define I2C_CLKL_I2CCLKL_S 0
  121. #define I2C_CLKL_I2CCLKL_M 0xFFFF // Clock low-time divide-down
  122. // value.
  123. //*****************************************************************************
  124. //
  125. // The following are defines for the bit fields in the I2CCLKH register
  126. //
  127. //*****************************************************************************
  128. #define I2C_CLKH_I2CCLKH_S 0
  129. #define I2C_CLKH_I2CCLKH_M 0xFFFF // Clock high-time divide-down
  130. // value.
  131. //*****************************************************************************
  132. //
  133. // The following are defines for the bit fields in the I2CCNT register
  134. //
  135. //*****************************************************************************
  136. #define I2C_CNT_I2CCNT_S 0
  137. #define I2C_CNT_I2CCNT_M 0xFFFF // Data count value.
  138. //*****************************************************************************
  139. //
  140. // The following are defines for the bit fields in the I2CDRR register
  141. //
  142. //*****************************************************************************
  143. #define I2C_DRR_DATA_S 0
  144. #define I2C_DRR_DATA_M 0xFF // Receive data
  145. //*****************************************************************************
  146. //
  147. // The following are defines for the bit fields in the I2CSAR register
  148. //
  149. //*****************************************************************************
  150. #define I2C_SAR_SAR_S 0
  151. #define I2C_SAR_SAR_M 0x3FF // Slave Address
  152. //*****************************************************************************
  153. //
  154. // The following are defines for the bit fields in the I2CDXR register
  155. //
  156. //*****************************************************************************
  157. #define I2C_DXR_DATA_S 0
  158. #define I2C_DXR_DATA_M 0xFF // Transmit data
  159. //*****************************************************************************
  160. //
  161. // The following are defines for the bit fields in the I2CMDR register
  162. //
  163. //*****************************************************************************
  164. #define I2C_MDR_BC_S 0
  165. #define I2C_MDR_BC_M 0x7 // Bit count bits.
  166. #define I2C_MDR_FDF 0x8 // Free Data Format
  167. #define I2C_MDR_STB 0x10 // START Byte Mode
  168. #define I2C_MDR_IRS 0x20 // I2C Module Reset
  169. #define I2C_MDR_DLB 0x40 // Digital Loopback Mode
  170. #define I2C_MDR_RM 0x80 // Repeat Mode
  171. #define I2C_MDR_XA 0x100 // Expanded Address Mode
  172. #define I2C_MDR_TRX 0x200 // Transmitter Mode
  173. #define I2C_MDR_MST 0x400 // Master Mode
  174. #define I2C_MDR_STP 0x800 // STOP Condition
  175. #define I2C_MDR_STT 0x2000 // START condition bit
  176. #define I2C_MDR_FREE 0x4000 // Debug Action
  177. #define I2C_MDR_NACKMOD 0x8000 // NACK mode bit
  178. //*****************************************************************************
  179. //
  180. // The following are defines for the bit fields in the I2CISRC register
  181. //
  182. //*****************************************************************************
  183. #define I2C_ISRC_INTCODE_S 0
  184. #define I2C_ISRC_INTCODE_M 0x7 // Interrupt code bits.
  185. //*****************************************************************************
  186. //
  187. // The following are defines for the bit fields in the I2CEMDR register
  188. //
  189. //*****************************************************************************
  190. #define I2C_EMDR_BC 0x1 // Backwards compatibility mode
  191. //*****************************************************************************
  192. //
  193. // The following are defines for the bit fields in the I2CPSC register
  194. //
  195. //*****************************************************************************
  196. #define I2C_PSC_IPSC_S 0
  197. #define I2C_PSC_IPSC_M 0xFF // I2C Prescaler Divide Down
  198. //*****************************************************************************
  199. //
  200. // The following are defines for the bit fields in the I2CFFTX register
  201. //
  202. //*****************************************************************************
  203. #define I2C_FFTX_TXFFIL_S 0
  204. #define I2C_FFTX_TXFFIL_M 0x1F // Transmit FIFO Interrupt Level
  205. #define I2C_FFTX_TXFFIENA 0x20 // Transmit FIFO Interrupt Enable
  206. #define I2C_FFTX_TXFFINTCLR 0x40 // Transmit FIFO Interrupt Flag
  207. // Clear
  208. #define I2C_FFTX_TXFFINT 0x80 // Transmit FIFO Interrupt Flag
  209. #define I2C_FFTX_TXFFST_S 8
  210. #define I2C_FFTX_TXFFST_M 0x1F00 // Transmit FIFO Status
  211. #define I2C_FFTX_TXFFRST 0x2000 // Transmit FIFO Reset
  212. #define I2C_FFTX_I2CFFEN 0x4000 // Transmit FIFO Enable
  213. //*****************************************************************************
  214. //
  215. // The following are defines for the bit fields in the I2CFFRX register
  216. //
  217. //*****************************************************************************
  218. #define I2C_FFRX_RXFFIL_S 0
  219. #define I2C_FFRX_RXFFIL_M 0x1F // Receive FIFO Interrupt Level
  220. #define I2C_FFRX_RXFFIENA 0x20 // Receive FIFO Interrupt Enable
  221. #define I2C_FFRX_RXFFINTCLR 0x40 // Receive FIFO Interrupt Flag
  222. // Clear
  223. #define I2C_FFRX_RXFFINT 0x80 // Receive FIFO Interrupt Flag
  224. #define I2C_FFRX_RXFFST_S 8
  225. #define I2C_FFRX_RXFFST_M 0x1F00 // Receive FIFO Status
  226. #define I2C_FFRX_RXFFRST 0x2000 // Receive FIFO Reset
  227. #endif