at91_twi.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. #ifndef _ARCH_ARM_AT91_TWI_H_
  2. #define _ARCH_ARM_AT91_TWI_H_
  3. /*
  4. * Copyright (C) 2006 by egnite Software GmbH. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the copyright holders nor the names of
  16. * contributors may be used to endorse or promote products derived
  17. * from this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  23. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  25. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  26. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  27. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  29. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. * SUCH DAMAGE.
  31. *
  32. * For additional information see http://www.ethernut.de/
  33. */
  34. /*!
  35. * \file arch/arm/at91_twi.h
  36. * \brief AT91 two wire interface.
  37. *
  38. * \verbatim
  39. *
  40. * $Log$
  41. * Revision 1.3 2008/01/31 09:14:50 haraldkipp
  42. * Duplicate Log tag removed.
  43. *
  44. * Revision 1.1 2006/08/31 19:19:55 haraldkipp
  45. * No time to write comments. ;-)
  46. *
  47. *
  48. * \endverbatim
  49. */
  50. /*!
  51. * \addtogroup xgNutArchArmAt91Twi
  52. */
  53. /*@{*/
  54. /*! \name TWI Control Register */
  55. /*@{*/
  56. #define TWI_CR_OFF 0x00000000 /*!< \brief Control register offset. */
  57. #define TWI_CR (TWI_BASE + TWI_CR_OFF) /*!< \brief Control register address. */
  58. #define TWI_START 0x00000001 /*!< \brief Send start condition. */
  59. #define TWI_STOP 0x00000002 /*!< \brief Send stop condition. */
  60. #define TWI_MSEN 0x00000004 /*!< \brief Enable master mode. */
  61. #define TWI_MSDIS 0x00000008 /*!< \brief Disable master mode. */
  62. #define TWI_SVEN 0x00000010 /*!< \brief Enable slave mode. */
  63. #define TWI_SVDIS 0x00000020 /*!< \brief Disable slave mode. */
  64. #define TWI_SWRST 0x00000080 /*!< \brief Software reset. */
  65. /*@}*/
  66. /*! \name TWI Master Mode Register */
  67. /*@{*/
  68. #define TWI_MMR_OFF 0x00000004 /*!< \brief Master mode register offset. */
  69. #define TWI_MMR (TWI_BASE + TWI_MMR_OFF) /*!< \brief Master mode register address. */
  70. #define TWI_IADRSZ 0x00000300 /*!< \brief Internal device address size mask. */
  71. #define TWI_IADRSZ_LSB 8 /*!< \brief Internal device address size LSB. */
  72. #define TWI_IADRSZ_NONE 0x00000000 /*!< \brief No internal device address. */
  73. #define TWI_IADRSZ_1BYTE 0x00000100 /*!< \brief One byte internal device address. */
  74. #define TWI_IADRSZ_2BYTE 0x00000200 /*!< \brief Two byte internal device address. */
  75. #define TWI_IADRSZ_3BYTE 0x00000300 /*!< \brief Three byte internal device address. */
  76. #define TWI_MREAD 0x00001000 /*!< \brief Master read direction. */
  77. #define TWI_DADR 0x007F0000 /*!< \brief Device address mask. */
  78. #define TWI_DADR_LSB 16 /*!< \brief Device address LSB. */
  79. /*@}*/
  80. /*! \name TWI Slave Mode Register */
  81. /*@{*/
  82. #define TWI_SMR_OFF 0x00000008 /*!< \brief Slave mode register offset. */
  83. #define TWI_SMR (TWI_BASE + TWI_SMR_OFF) /*!< \brief Slave mode register address. */
  84. #define TWI_SADR 0x007F0000 /*!< \brief Slave address mask. */
  85. #define TWI_SADR_LSB 16 /*!< \brief Slave address LSB. */
  86. /*@}*/
  87. /*! \name TWI Internal Address Register */
  88. /*@{*/
  89. #define TWI_IADRR_OFF 0x0000000C /*!< \brief Internal address register offset. */
  90. #define TWI_IADRR (TWI_BASE + TWI_IADRR_OFF) /*!< \brief Internal address register address. */
  91. #define TWI_IADR 0x00FFFFFF /*!< \brief Internal address mask. */
  92. #define TWI_IADR_LSB 0 /*!< \brief Internal address LSB. */
  93. /*@}*/
  94. /*! \name TWI Clock Waveform Generator Register */
  95. /*@{*/
  96. #define TWI_CWGR_OFF 0x00000010 /*!< \brief Clock waveform generator register offset. */
  97. #define TWI_CWGR (TWI_BASE + TWI_CWGR_OFF) /*!< \brief Clock waveform generator register address. */
  98. #define TWI_CLDIV 0x000000FF /*!< \brief Clock low divider mask. */
  99. #define TWI_CLDIV_LSB 0 /*!< \brief Clock low divider LSB. */
  100. #define TWI_CHDIV 0x0000FF00 /*!< \brief Clock high divider mask. */
  101. #define TWI_CHDIV_LSB 8 /*!< \brief Clock high divider LSB. */
  102. #define TWI_CKDIV 0x00070000 /*!< \brief Clock divider mask. */
  103. #define TWI_CKDIV_LSB 16 /*!< \brief Clock divider LSB. */
  104. /*@}*/
  105. /*! \name TWI Status and Interrupt Registers */
  106. /*@{*/
  107. #define TWI_SR_OFF 0x00000020 /*!< \brief Status register offset. */
  108. #define TWI_SR (TWI_BASE + TWI_SR_OFF) /*!< \brief Status register address. */
  109. #define TWI_IER_OFF 0x00000024 /*!< \brief Interrupt enable register offset. */
  110. #define TWI_IER (TWI_BASE + TWI_IER_OFF) /*!< \brief Interrupt enable register address. */
  111. #define TWI_IDR_OFF 0x00000028 /*!< \brief Interrupt disable register offset. */
  112. #define TWI_IDR (TWI_BASE + TWI_IDR_OFF) /*!< \brief Interrupt disable register address. */
  113. #define TWI_IMR_OFF 0x0000002C /*!< \brief Interrupt mask register offset. */
  114. #define TWI_IMR (TWI_BASE + TWI_IMR_OFF) /*!< \brief Interrupt mask register address. */
  115. #define TWI_TXCOMP 0x00000001 /*!< \brief Transmission completed. */
  116. #define TWI_RXRDY 0x00000002 /*!< \brief Receive holding register ready. */
  117. #define TWI_TXRDY 0x00000004 /*!< \brief Transmit holding register ready. */
  118. #define TWI_SVREAD 0x00000008 /*!< \brief Slave read. */
  119. #define TWI_SVACC 0x00000010 /*!< \brief Slave access. */
  120. #define TWI_GACC 0x00000020 /*!< \brief General call access. */
  121. #define TWI_OVRE 0x00000040 /*!< \brief Overrun error. */
  122. #define TWI_NACK 0x00000100 /*!< \brief Not acknowledged. */
  123. #define TWI_ARBLST 0x00000200 /*!< \brief Arbitration lost. */
  124. #define TWI_SCLWS 0x00000400 /*!< \brief Clock wait state. */
  125. #define TWI_EOSACC 0x00000800 /*!< \brief End of slave access. */
  126. /*@}*/
  127. /*! \name TWI Receive Holding Register */
  128. /*@{*/
  129. #define TWI_RHR_OFF 0x00000030 /*!< \brief Receive holding register offset. */
  130. #define TWI_RHR (TWI_BASE + TWI_RHR_OFF) /*!< \brief Receive holding register address. */
  131. /*@}*/
  132. /*! \name TWI Transmit Holding Register */
  133. /*@{*/
  134. #define TWI_THR_OFF 0x00000034 /*!< \brief Transmit holding register offset. */
  135. #define TWI_THR (TWI_BASE + TWI_THR_OFF) /*!< \brief Transmit holding register address. */
  136. /*@}*/
  137. /*@} xgNutArchArmAt91Twi */
  138. #endif /* _ARCH_ARM_AT91_TWI_H_ */