hw_i2cm.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. /******************************************************************************
  2. * Filename: hw_i2cm.h
  3. * Revised: $Date: 2013-04-30 17:13:44 +0200 (Tue, 30 Apr 2013) $
  4. * Revision: $Revision: 9943 $
  5. *
  6. * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
  7. *
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that the following conditions
  11. * are met:
  12. *
  13. * Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions and the following disclaimer.
  15. *
  16. * Redistributions in binary form must reproduce the above copyright
  17. * notice, this list of conditions and the following disclaimer in the
  18. * documentation and/or other materials provided with the 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. ******************************************************************************/
  37. #ifndef __HW_I2CM_H__
  38. #define __HW_I2CM_H__
  39. //*****************************************************************************
  40. //
  41. // The following are defines for the I2CM register offsets.
  42. //
  43. //*****************************************************************************
  44. #define I2CM_SA 0x40020000 // I2C master slave address This
  45. // register consists of eight bits,
  46. // seven address bits (A6-A0), and
  47. // a receive and send bit, which
  48. // determines if the next operation
  49. // is a receive (high) or transmit
  50. // (low).
  51. #define I2CM_CTRL 0x40020004 // I2C master control and status
  52. // This register accesses status
  53. // bits when read and control bits
  54. // when written. When read, the
  55. // status register indicates the
  56. // state of the I2C bus controller.
  57. // When written, the control
  58. // register configures the I2C
  59. // controller operation. The START
  60. // bit generates the START or
  61. // REPEATED START condition. The
  62. // STOP bit determines if the cycle
  63. // stops at the end of the data
  64. // cycle or continues on to a
  65. // repeated START condition. To
  66. // generate a single transmit
  67. // cycle, the I2C master slave
  68. // address (I2CMSA) register is
  69. // written with the desired
  70. // address, the R/S bit is cleared,
  71. // and this register is written
  72. // with ACK = X (0 or 1), STOP = 1,
  73. // START = 1, and RUN = 1 to
  74. // perform the operation and stop.
  75. // When the operation is completed
  76. // (or aborted due an error), an
  77. // interrupt becomes active and the
  78. // data may be read from the I2CMDR
  79. // register. When the I2C module
  80. // operates in master receiver
  81. // mode, the ACK bit is normally
  82. // set, causing the I2C bus
  83. // controller to automatically
  84. // transmit an acknowledge after
  85. // each byte. This bit must be
  86. // cleared when the I2C bus
  87. // controller requires no further
  88. // data to be transmitted from the
  89. // slave transmitter.
  90. #define I2CM_STAT 0x40020004 // I2C master control and status
  91. // This register accesses status
  92. // bits when read and control bits
  93. // when written. When read, the
  94. // status register indicates the
  95. // state of the I2C bus controller.
  96. // When written, the control
  97. // register configures the I2C
  98. // controller operation. The START
  99. // bit generates the START or
  100. // REPEATED START condition. The
  101. // STOP bit determines if the cycle
  102. // stops at the end of the data
  103. // cycle or continues on to a
  104. // repeated START condition. To
  105. // generate a single transmit
  106. // cycle, the I2C master slave
  107. // address (I2CMSA) register is
  108. // written with the desired
  109. // address, the R/S bit is cleared,
  110. // and this register is written
  111. // with ACK = X (0 or 1), STOP = 1,
  112. // START = 1, and RUN = 1 to
  113. // perform the operation and stop.
  114. // When the operation is completed
  115. // (or aborted due an error), an
  116. // interrupt becomes active and the
  117. // data may be read from the I2CMDR
  118. // register. When the I2C module
  119. // operates in master receiver
  120. // mode, the ACK bit is normally
  121. // set, causing the I2C bus
  122. // controller to automatically
  123. // transmit an acknowledge after
  124. // each byte. This bit must be
  125. // cleared when the I2C bus
  126. // controller requires no further
  127. // data to be transmitted from the
  128. // slave transmitter.
  129. #define I2CM_DR 0x40020008 // I2C master data This register
  130. // contains the data to be
  131. // transmitted when in the master
  132. // transmit state and the data
  133. // received when in the master
  134. // receive state.
  135. #define I2CM_TPR 0x4002000C // I2C master timer period This
  136. // register specifies the period of
  137. // the SCL clock.
  138. #define I2CM_IMR 0x40020010 // I2C master interrupt mask This
  139. // register controls whether a raw
  140. // interrupt is promoted to a
  141. // controller interrupt.
  142. #define I2CM_RIS 0x40020014 // I2C master raw interrupt status
  143. // This register specifies whether
  144. // an interrupt is pending.
  145. #define I2CM_MIS 0x40020018 // I2C master masked interrupt
  146. // status This register specifies
  147. // whether an interrupt was
  148. // signaled.
  149. #define I2CM_ICR 0x4002001C // I2C master interrupt clear This
  150. // register clears the raw and
  151. // masked interrupts.
  152. #define I2CM_CR 0x40020020 // I2C master configuration This
  153. // register configures the mode
  154. // (master or slave) and sets the
  155. // interface for test mode
  156. // loopback.
  157. //*****************************************************************************
  158. //
  159. // The following are defines for the bit fields in the I2CM_SA register.
  160. //
  161. //*****************************************************************************
  162. #define I2CM_SA_SA_M 0x000000FE // I2C slave address
  163. #define I2CM_SA_SA_S 1
  164. #define I2CM_SA_RS 0x00000001 // Receive and send The R/S bit
  165. // specifies if the next operation
  166. // is a receive (high) or transmit
  167. // (low). 0: Transmit 1: Receive
  168. #define I2CM_SA_RS_M 0x00000001
  169. #define I2CM_SA_RS_S 0
  170. //*****************************************************************************
  171. //
  172. // The following are defines for the bit fields in the I2CM_CTRL register.
  173. //
  174. //*****************************************************************************
  175. #define I2CM_CTRL_ACK 0x00000008 // Data acknowledge enable 0: The
  176. // received data byte is not
  177. // acknowledged automatically by
  178. // the master. 1: The received data
  179. // byte is acknowledged
  180. // automatically by the master.
  181. #define I2CM_CTRL_ACK_M 0x00000008
  182. #define I2CM_CTRL_ACK_S 3
  183. #define I2CM_CTRL_STOP 0x00000004 // Generate STOP 0: The controller
  184. // does not generate the STOP
  185. // condition. 1: The controller
  186. // generates the STOP condition.
  187. #define I2CM_CTRL_STOP_M 0x00000004
  188. #define I2CM_CTRL_STOP_S 2
  189. #define I2CM_CTRL_START 0x00000002 // Generate START 0: The
  190. // controller does not generate the
  191. // START condition. 1: The
  192. // controller generates the START
  193. // condition.
  194. #define I2CM_CTRL_START_M 0x00000002
  195. #define I2CM_CTRL_START_S 1
  196. #define I2CM_CTRL_RUN 0x00000001 // I2C master enable 0: The master
  197. // is disabled. 1: The master is
  198. // enabled to transmit or receive
  199. // data. When the BUSY bit is set,
  200. // the other status bits are not
  201. // valid.
  202. #define I2CM_CTRL_RUN_M 0x00000001
  203. #define I2CM_CTRL_RUN_S 0
  204. //*****************************************************************************
  205. //
  206. // The following are defines for the bit fields in the I2CM_STAT register.
  207. //
  208. //*****************************************************************************
  209. #define I2CM_STAT_BUSBSY 0x00000040 // Bus busy 0: The I2C bus is
  210. // idle. 1: The I2C bus is busy.
  211. // The bit changes based on the
  212. // START and STOP conditions.
  213. #define I2CM_STAT_BUSBSY_M 0x00000040
  214. #define I2CM_STAT_BUSBSY_S 6
  215. #define I2CM_STAT_IDLE 0x00000020 // I2C idle 0: The I2C controller
  216. // is not idle. 1: The I2C
  217. // controller is idle.
  218. #define I2CM_STAT_IDLE_M 0x00000020
  219. #define I2CM_STAT_IDLE_S 5
  220. #define I2CM_STAT_ARBLST 0x00000010 // Arbitration lost 0: The I2C
  221. // controller won arbitration. 1:
  222. // The I2C controller lost
  223. // arbitration.
  224. #define I2CM_STAT_ARBLST_M 0x00000010
  225. #define I2CM_STAT_ARBLST_S 4
  226. #define I2CM_STAT_DATACK 0x00000008 // Acknowledge data 0: The
  227. // transmited data was
  228. // acknowledged. 1: The transmited
  229. // data was not acknowledged.
  230. #define I2CM_STAT_DATACK_M 0x00000008
  231. #define I2CM_STAT_DATACK_S 3
  232. #define I2CM_STAT_ADRACK 0x00000004 // Acknowledge address 0: The
  233. // transmited address was
  234. // acknowledged. 1: The transmited
  235. // address was not acknowledged.
  236. #define I2CM_STAT_ADRACK_M 0x00000004
  237. #define I2CM_STAT_ADRACK_S 2
  238. #define I2CM_STAT_ERROR 0x00000002 // Error 0: No error was detected
  239. // on the last operation. 1: An
  240. // error occurred on the last
  241. // operation.
  242. #define I2CM_STAT_ERROR_M 0x00000002
  243. #define I2CM_STAT_ERROR_S 1
  244. #define I2CM_STAT_BUSY 0x00000001 // I2C busy 0: The controller is
  245. // idle. 1: The controller is busy.
  246. // When the BUSY bit is set, the
  247. // other status bits are not valid.
  248. #define I2CM_STAT_BUSY_M 0x00000001
  249. #define I2CM_STAT_BUSY_S 0
  250. //*****************************************************************************
  251. //
  252. // The following are defines for the bit fields in the I2CM_DR register.
  253. //
  254. //*****************************************************************************
  255. #define I2CM_DR_DATA_M 0x000000FF // Data transferred Data
  256. // transferred during transaction
  257. #define I2CM_DR_DATA_S 0
  258. //*****************************************************************************
  259. //
  260. // The following are defines for the bit fields in the I2CM_TPR register.
  261. //
  262. //*****************************************************************************
  263. #define I2CM_TPR_TPR_M 0x0000007F // SCL clock period This field
  264. // specifies the period of the SCL
  265. // clock. SCL_PRD = 2 *
  266. // (1+TPR)*(SCL_LP +
  267. // SCL_HP)*CLK_PRD where: SCL_PRD
  268. // is the SCL line period (I2C
  269. // clock). TPR is the timer period
  270. // register value (range of 1 to
  271. // 127) SCL_LP is the SCL low
  272. // period (fixed at 6). SCL_HP is
  273. // the SCL high period (fixed at
  274. // 4). CLK_PRD is the system clock
  275. // period in ns.
  276. #define I2CM_TPR_TPR_S 0
  277. //*****************************************************************************
  278. //
  279. // The following are defines for the bit fields in the I2CM_IMR register.
  280. //
  281. //*****************************************************************************
  282. #define I2CM_IMR_IM 0x00000001 // Interrupt mask 1: The master
  283. // interrupt is sent to the
  284. // interrupt controller when the
  285. // RIS bit in the I2CMRIS register
  286. // is set. 0: The RIS interrupt is
  287. // suppressed and not sent to the
  288. // interrupt controller.
  289. #define I2CM_IMR_IM_M 0x00000001
  290. #define I2CM_IMR_IM_S 0
  291. //*****************************************************************************
  292. //
  293. // The following are defines for the bit fields in the I2CM_RIS register.
  294. //
  295. //*****************************************************************************
  296. #define I2CM_RIS_RIS 0x00000001 // Raw interrupt status 1: A
  297. // master interrupt is pending. 0:
  298. // No interrupt This bit is cleared
  299. // by writing 1 to the IC bit in
  300. // the I2CMICR register.
  301. #define I2CM_RIS_RIS_M 0x00000001
  302. #define I2CM_RIS_RIS_S 0
  303. //*****************************************************************************
  304. //
  305. // The following are defines for the bit fields in the I2CM_MIS register.
  306. //
  307. //*****************************************************************************
  308. #define I2CM_MIS_MIS 0x00000001 // Masked interrupt status 1: An
  309. // unmasked master interrupt is
  310. // pending. 0: An interrupt has not
  311. // occurred or is masked. This bit
  312. // is cleared by writing 1 to the
  313. // IC bit in the I2CMICR register.
  314. #define I2CM_MIS_MIS_M 0x00000001
  315. #define I2CM_MIS_MIS_S 0
  316. //*****************************************************************************
  317. //
  318. // The following are defines for the bit fields in the I2CM_ICR register.
  319. //
  320. //*****************************************************************************
  321. #define I2CM_ICR_IC 0x00000001 // Interrupt clear Writing 1 to
  322. // this bit clears the RIS bit in
  323. // the I2CMRIS register and the MIS
  324. // bit in the I2CMMIS register.
  325. // Reading this register returns no
  326. // meaningful data.
  327. #define I2CM_ICR_IC_M 0x00000001
  328. #define I2CM_ICR_IC_S 0
  329. //*****************************************************************************
  330. //
  331. // The following are defines for the bit fields in the I2CM_CR register.
  332. //
  333. //*****************************************************************************
  334. #define I2CM_CR_SFE 0x00000020 // I2C slave function enable 1:
  335. // Slave mode is enabled. 0: Slave
  336. // mode is disabled.
  337. #define I2CM_CR_SFE_M 0x00000020
  338. #define I2CM_CR_SFE_S 5
  339. #define I2CM_CR_MFE 0x00000010 // I2C master function enable 1:
  340. // Master mode is enabled. 0:
  341. // Master mode is disabled.
  342. #define I2CM_CR_MFE_M 0x00000010
  343. #define I2CM_CR_MFE_S 4
  344. #define I2CM_CR_LPBK 0x00000001 // I2C loopback 1: The controller
  345. // in a test mode loopback
  346. // configuration. 0: Normal
  347. // operation
  348. #define I2CM_CR_LPBK_M 0x00000001
  349. #define I2CM_CR_LPBK_S 0
  350. #endif // __HW_I2CM_H__