F2837xD_I2c_defines.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. //###########################################################################
  2. //
  3. // FILE: F2837xD_I2c_defines.h
  4. //
  5. // TITLE: F2837xD I2C Common Definitions.
  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 F2837xD_I2C_DEFINES_H
  43. #define F2837xD_I2C_DEFINES_H
  44. //
  45. // Defines
  46. //
  47. //
  48. // Error Messages
  49. //
  50. #define I2C_ERROR 0xFFFF
  51. #define I2C_ARB_LOST_ERROR 0x0001
  52. #define I2C_NACK_ERROR 0x0002
  53. #define I2C_BUS_BUSY_ERROR 0x1000
  54. #define I2C_STP_NOT_READY_ERROR 0x5555
  55. #define I2C_NO_FLAGS 0xAAAA
  56. #define I2C_SUCCESS 0x0000
  57. //
  58. // Clear Status Flags
  59. //
  60. #define I2C_CLR_AL_BIT 0x0001
  61. #define I2C_CLR_NACK_BIT 0x0002
  62. #define I2C_CLR_ARDY_BIT 0x0004
  63. #define I2C_CLR_RRDY_BIT 0x0008
  64. #define I2C_CLR_SCD_BIT 0x0020
  65. //
  66. // Interrupt Source Messages
  67. //
  68. #define I2C_NO_ISRC 0x0000
  69. #define I2C_ARB_ISRC 0x0001
  70. #define I2C_NACK_ISRC 0x0002
  71. #define I2C_ARDY_ISRC 0x0003
  72. #define I2C_RX_ISRC 0x0004
  73. #define I2C_TX_ISRC 0x0005
  74. #define I2C_SCD_ISRC 0x0006
  75. #define I2C_AAS_ISRC 0x0007
  76. //
  77. // I2CMSG structure defines
  78. //
  79. #define I2C_NO_STOP 0
  80. #define I2C_YES_STOP 1
  81. #define I2C_RECEIVE 0
  82. #define I2C_TRANSMIT 1
  83. #define I2C_MAX_BUFFER_SIZE 16
  84. //
  85. // I2C Slave State defines
  86. //
  87. #define I2C_NOTSLAVE 0
  88. #define I2C_ADDR_AS_SLAVE 1
  89. #define I2C_ST_MSG_READY 2
  90. //
  91. // I2C Slave Receiver messages defines
  92. //
  93. #define I2C_SND_MSG1 1
  94. #define I2C_SND_MSG2 2
  95. //
  96. // I2C State defines
  97. //
  98. #define I2C_IDLE 0
  99. #define I2C_SLAVE_RECEIVER 1
  100. #define I2C_SLAVE_TRANSMITTER 2
  101. #define I2C_MASTER_RECEIVER 3
  102. #define I2C_MASTER_TRANSMITTER 4
  103. //
  104. // I2C Message Commands for I2CMSG struct
  105. //
  106. #define I2C_MSGSTAT_INACTIVE 0x0000
  107. #define I2C_MSGSTAT_SEND_WITHSTOP 0x0010
  108. #define I2C_MSGSTAT_WRITE_BUSY 0x0011
  109. #define I2C_MSGSTAT_SEND_NOSTOP 0x0020
  110. #define I2C_MSGSTAT_SEND_NOSTOP_BUSY 0x0021
  111. #define I2C_MSGSTAT_RESTART 0x0022
  112. #define I2C_MSGSTAT_READ_BUSY 0x0023
  113. //
  114. // Generic defines
  115. //
  116. #define I2C_TRUE 1
  117. #define I2C_FALSE 0
  118. #define I2C_YES 1
  119. #define I2C_NO 0
  120. #define I2C_DUMMY_BYTE 0
  121. //
  122. // These are the Defines to select I2C pin muxing when calling the functions
  123. // I2cAGpioConfig() & I2cBGpioConfig() in F2837xD_I2C.c
  124. //
  125. #define I2C_A_GPIO0_GPIO1 1 //switch case 1
  126. #define I2C_A_GPIO32_GPIO33 2 //switch case 2
  127. #define I2C_A_GPIO42_GPIO43 3 //switch case 3
  128. #define I2C_A_GPIO91_GPIO92 4 //switch case 4
  129. #define I2C_A_GPIO63104_GPIO105 5 //switch case 5
  130. #define I2C_B_GPIO2_GPIO3 1 //switch case 1
  131. #define I2C_B_GPIO134_GPIO35 2 //switch case 2
  132. #define I2C_B_GPIO40_GPIO41 3 //switch case 3
  133. #define I2C_B_GPIO66_GPIO69 4 //switch case 4
  134. //
  135. // Globals
  136. //
  137. //
  138. // I2C Message Structure
  139. //
  140. struct I2CMSG {
  141. Uint16 MsgStatus; // Word stating what state msg is in:
  142. // I2C_MSGCMD_INACTIVE = do not send msg
  143. // I2C_MSGCMD_BUSY = msg start has been sent,
  144. // awaiting stop
  145. // I2C_MSGCMD_SEND_WITHSTOP = command to send
  146. // master trans msg complete with a stop bit
  147. // I2C_MSGCMD_SEND_NOSTOP = command to send
  148. // master trans msg without the stop bit
  149. // I2C_MSGCMD_RESTART = command to send a
  150. // restart as a master receiver with a
  151. // stop bit
  152. Uint16 SlaveAddress; // I2C address of slave msg is intended for
  153. Uint16 NumOfBytes; // Num of valid bytes in (or to be put
  154. // in MsgBuffer)
  155. Uint16 MemoryHighAddr; // EEPROM address of data associated with
  156. // msg (high byte)
  157. Uint16 MemoryLowAddr; // EEPROM address of data associated with
  158. // msg (low byte)
  159. Uint16 MsgBuffer[I2C_MAX_BUFFER_SIZE]; // Array holding msg data - max that
  160. // MAX_BUFFER_SIZE can be is 16 due
  161. // to the FIFO's
  162. };
  163. #endif // end of F2837xD_I2C_DEFINES_H definition
  164. //
  165. // End of file
  166. //