lpc_i2c.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. #ifndef _ARCH_CM3_NXP_MACH_LPC_I2C_H_
  2. #define _ARCH_CM3_NXP_MACH_LPC_I2C_H_
  3. /*
  4. * Copyright 2012 by egnite GmbH
  5. *
  6. * All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. * 2. Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in the
  16. * documentation and/or other materials provided with the distribution.
  17. * 3. Neither the name of the copyright holders nor the names of
  18. * contributors may be used to endorse or promote products derived
  19. * from this software without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  24. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  25. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  26. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  27. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  28. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  29. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  31. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  32. * SUCH DAMAGE.
  33. *
  34. * For additional information see http://www.ethernut.de/
  35. */
  36. /*!
  37. * \file arch/cm3/nxp/mach/lpc_i2c.h
  38. * \brief LPC I2C definitions
  39. *
  40. * \verbatim
  41. * $Id$
  42. * \endverbatim
  43. */
  44. /*!
  45. * \addtogroup xgNutArchCm3LpcI2c
  46. */
  47. /*@{*/
  48. /*! \name I2C Control Set Register */
  49. /*@{*/
  50. #define I2C_CONSET_OFF 0x0000
  51. #define I2C0CONSET (LPC_I2C0_BASE + I2C_CONSET_OFF)
  52. #define I2C1CONSET (LPC_I2C1_BASE + I2C_CONSET_OFF)
  53. #define I2C_CONSET_AA _BV(2)
  54. #define I2C_CONSET_SI _BV(3)
  55. #define I2C_CONSET_STO _BV(4)
  56. #define I2C_CONSET_STA _BV(5)
  57. #define I2C_CONSET_I2EN _BV(6)
  58. /*@}*/
  59. /*! \name I2C Control Clear Register */
  60. /*@{*/
  61. #define I2C_CONCLR_OFF 0x0018
  62. #define I2C0CONCLR (LPC_I2C0_BASE + I2C_CONCLR_OFF)
  63. #define I2C1CONCLR (LPC_I2C1_BASE + I2C_CONCLR_OFF)
  64. #define I2C_CONCLR_AAC _BV(2)
  65. #define I2C_CONCLR_SIC _BV(3)
  66. #define I2C_CONCLR_STAC _BV(5)
  67. #define I2C_CONCLR_I2ENC _BV(6)
  68. /*@}*/
  69. /*! \name I2C Status Register */
  70. /*@{*/
  71. #define I2C_STAT_OFF 0x0004
  72. #define I2C0STAT (LPC_I2C0_BASE + I2C_STAT_OFF)
  73. #define I2C1STAT (LPC_I2C1_BASE + I2C_STAT_OFF)
  74. /*@}*/
  75. /*! \name I2C Data Register */
  76. /*@{*/
  77. #define I2C_DAT_OFF 0x0008
  78. #define I2C0DAT (LPC_I2C0_BASE + I2C_DAT_OFF)
  79. #define I2C1DAT (LPC_I2C1_BASE + I2C_DAT_OFF)
  80. /*@}*/
  81. /*! \name I2C Slave Address Registers */
  82. /*@{*/
  83. #define I2C_ADR0_OFF 0x000C
  84. #define I2C_ADR1_OFF 0x0020
  85. #define I2C_ADR2_OFF 0x0024
  86. #define I2C_ADR3_OFF 0x0028
  87. #define I2C0ADR0 (LPC_I2C0_BASE + I2C_ADR0_OFF)
  88. #define I2C0ADR1 (LPC_I2C0_BASE + I2C_ADR1_OFF)
  89. #define I2C0ADR2 (LPC_I2C0_BASE + I2C_ADR2_OFF)
  90. #define I2C0ADR3 (LPC_I2C0_BASE + I2C_ADR3_OFF)
  91. #define I2C1ADR0 (LPC_I2C1_BASE + I2C_ADR0_OFF)
  92. #define I2C1ADR1 (LPC_I2C1_BASE + I2C_ADR1_OFF)
  93. #define I2C1ADR2 (LPC_I2C1_BASE + I2C_ADR2_OFF)
  94. #define I2C1ADR3 (LPC_I2C1_BASE + I2C_ADR3_OFF)
  95. #define I2C_ADR_GC _BV(0)
  96. /*@}*/
  97. /*! \name I2C Slave Address Mask Registers */
  98. /*@{*/
  99. #define I2C_MASK0_OFF 0x0030
  100. #define I2C_MASK1_OFF 0x0034
  101. #define I2C_MASK2_OFF 0x0038
  102. #define I2C_MASK3_OFF 0x003C
  103. #define I2C0MASK0 (LPC_I2C0_BASE + I2C_MASK0_OFF)
  104. #define I2C0MASK1 (LPC_I2C0_BASE + I2C_MASK1_OFF)
  105. #define I2C0MASK2 (LPC_I2C0_BASE + I2C_MASK2_OFF)
  106. #define I2C0MASK3 (LPC_I2C0_BASE + I2C_MASK3_OFF)
  107. #define I2C1MASK0 (LPC_I2C1_BASE + I2C_MASK0_OFF)
  108. #define I2C1MASK1 (LPC_I2C1_BASE + I2C_MASK1_OFF)
  109. #define I2C1MASK2 (LPC_I2C1_BASE + I2C_MASK2_OFF)
  110. #define I2C1MASK3 (LPC_I2C1_BASE + I2C_MASK3_OFF)
  111. /*@}*/
  112. /*! \name Duty Cycle Registers */
  113. /*@{*/
  114. #define I2C_SCLL_OFF 0x0014
  115. #define I2C0SCLL (LPC_I2C0_BASE + I2C_SCLL_OFF)
  116. #define I2C1SCLL (LPC_I2C1_BASE + I2C_SCLL_OFF)
  117. #define I2C_SCLH_OFF 0x0010
  118. #define I2C0SCLH (LPC_I2C0_BASE + I2C_SCLH_OFF)
  119. #define I2C1SCLH (LPC_I2C1_BASE + I2C_SCLH_OFF)
  120. /*@}*/
  121. /*! \name I2C Monitor Mode Control Register */
  122. /*@{*/
  123. #define I2C_MMCTRL_OFF 0x001C
  124. #define I2C0MMCTRL (LPC_I2C0_BASE + I2C_MMCTRL_OFF)
  125. #define I2C1MMCTRL (LPC_I2C1_BASE + I2C_MMCTRL_OFF)
  126. #define I2C_MMCTRL_MM_ENA _BV(0)
  127. #define I2C_MMCTRL_ENA_SCL _BV(1)
  128. #define I2C_MMCTRL_MATCH_ALL _BV(2)
  129. /*@}*/
  130. /*! \name I2C Data Buffer Register */
  131. /*@{*/
  132. #define I2C_DATA_BUFFER_OFF 0x002C
  133. #define I2C0DATA_BUFFER (LPC_I2C0_BASE + I2C_DATA_BUFFER_OFF)
  134. #define I2C1DATA_BUFFER (LPC_I2C1_BASE + I2C_DATA_BUFFER_OFF)
  135. /*@}*/
  136. /*@}*/
  137. #endif