at91_twi.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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 EGNITE SOFTWARE GMBH 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 EGNITE
  23. * SOFTWARE GMBH 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: at91_twi.h,v $
  41. * Revision 1.1 2006/08/31 19:19:55 haraldkipp
  42. * No time to write comments. ;-)
  43. *
  44. *
  45. * \endverbatim
  46. */
  47. /*!
  48. * \addtogroup xgNutArchArmAt91Twi
  49. */
  50. /*@{*/
  51. /*! \name TWI Control Register */
  52. /*@{*/
  53. #define TWI_CR_OFF 0x00000000 /*!< \brief Control register offset. */
  54. #define TWI_CR (TWI_BASE + TWI_CR_OFF) /*!< \brief Control register address. */
  55. #define TWI_START 0x00000001 /*!< \brief Send start condition. */
  56. #define TWI_STOP 0x00000002 /*!< \brief Send stop condition. */
  57. #define TWI_MSEN 0x00000004 /*!< \brief Enable master mode. */
  58. #define TWI_MSDIS 0x00000008 /*!< \brief Disable master mode. */
  59. #define TWI_SVEN 0x00000010 /*!< \brief Enable slave mode. */
  60. #define TWI_SVDIS 0x00000020 /*!< \brief Disable slave mode. */
  61. #define TWI_SWRST 0x00000080 /*!< \brief Software reset. */
  62. /*@}*/
  63. /*! \name TWI Master Mode Register */
  64. /*@{*/
  65. #define TWI_MMR_OFF 0x00000004 /*!< \brief Master mode register offset. */
  66. #define TWI_MMR (TWI_BASE + TWI_MMR_OFF) /*!< \brief Master mode register address. */
  67. #define TWI_IADRSZ 0x00000300 /*!< \brief Internal device address size mask. */
  68. #define TWI_IADRSZ_NONE 0x00000000 /*!< \brief No internal device address. */
  69. #define TWI_IADRSZ_1BYTE 0x00000100 /*!< \brief One byte internal device address. */
  70. #define TWI_IADRSZ_2BYTE 0x00000200 /*!< \brief Two byte internal device address. */
  71. #define TWI_IADRSZ_3BYTE 0x00000300 /*!< \brief Three byte internal device address. */
  72. #define TWI_MREAD 0x00001000 /*!< \brief Master read direction. */
  73. #define TWI_DADR 0x007F0000 /*!< \brief Device address mask. */
  74. #define TWI_DADR_LSB 16 /*!< \brief Device address LSB. */
  75. /*@}*/
  76. /*! \name TWI Slave Mode Register */
  77. /*@{*/
  78. #define TWI_SMR_OFF 0x00000008 /*!< \brief Slave mode register offset. */
  79. #define TWI_SMR (TWI_BASE + TWI_SMR_OFF) /*!< \brief Slave mode register address. */
  80. #define TWI_SADR 0x007F0000 /*!< \brief Slave address mask. */
  81. #define TWI_SADR_LSB 16 /*!< \brief Slave address LSB. */
  82. /*@}*/
  83. /*! \name TWI Internal Address Register */
  84. /*@{*/
  85. #define TWI_IADRR_OFF 0x0000000C /*!< \brief Internal address register offset. */
  86. #define TWI_IADRR (TWI_BASE + TWI_IADRR_OFF) /*!< \brief Internal address register address. */
  87. #define TWI_IADR 0x00FFFFFF /*!< \brief Internal address mask. */
  88. #define TWI_IADR_LSB 0 /*!< \brief Internal address LSB. */
  89. /*@}*/
  90. /*! \name TWI Clock Waveform Generator Register */
  91. /*@{*/
  92. #define TWI_CWGR_OFF 0x00000010 /*!< \brief Clock waveform generator register offset. */
  93. #define TWI_CWGR (TWI_BASE + TWI_CWGR_OFF) /*!< \brief Clock waveform generator register address. */
  94. #define TWI_CLDIV 0x000000FF /*!< \brief Clock low divider mask. */
  95. #define TWI_CLDIV_LSB 0 /*!< \brief Clock low divider LSB. */
  96. #define TWI_CHDIV 0x0000FF00 /*!< \brief Clock high divider mask. */
  97. #define TWI_CHDIV_LSB 8 /*!< \brief Clock high divider LSB. */
  98. #define TWI_CKDIV 0x00070000 /*!< \brief Clock divider mask. */
  99. #define TWI_CKDIV_LSB 16 /*!< \brief Clock divider LSB. */
  100. /*@}*/
  101. /*! \name TWI Status and Interrupt Registers */
  102. /*@{*/
  103. #define TWI_SR_OFF 0x00000020 /*!< \brief Status register offset. */
  104. #define TWI_SR (TWI_BASE + TWI_SR_OFF) /*!< \brief Status register address. */
  105. #define TWI_IER_OFF 0x00000024 /*!< \brief Interrupt enable register offset. */
  106. #define TWI_IER (TWI_BASE + TWI_IER_OFF) /*!< \brief Interrupt enable register address. */
  107. #define TWI_IDR_OFF 0x00000028 /*!< \brief Interrupt disable register offset. */
  108. #define TWI_IDR (TWI_BASE + TWI_IDR_OFF) /*!< \brief Interrupt disable register address. */
  109. #define TWI_IMR_OFF 0x0000002C /*!< \brief Interrupt mask register offset. */
  110. #define TWI_IMR (TWI_BASE + TWI_IMR_OFF) /*!< \brief Interrupt mask register address. */
  111. #define TWI_TXCOMP 0x00000001 /*!< \brief Transmission completed. */
  112. #define TWI_RXRDY 0x00000002 /*!< \brief Receive holding register ready. */
  113. #define TWI_TXRDY 0x00000004 /*!< \brief Transmit holding register ready. */
  114. #define TWI_SVREAD 0x00000008 /*!< \brief Slave read. */
  115. #define TWI_SVACC 0x00000010 /*!< \brief Slave access. */
  116. #define TWI_GACC 0x00000020 /*!< \brief General call access. */
  117. #define TWI_OVRE 0x00000040 /*!< \brief Overrun error. */
  118. #define TWI_NACK 0x00000100 /*!< \brief Not acknowledged. */
  119. #define TWI_ARBLST 0x00000200 /*!< \brief Arbitration lost. */
  120. #define TWI_SCLWS 0x00000400 /*!< \brief Clock wait state. */
  121. #define TWI_EOSACC 0x00000800 /*!< \brief End of slave access. */
  122. /*@}*/
  123. /*! \name TWI Receive Holding Register */
  124. /*@{*/
  125. #define TWI_RHR_OFF 0x00000030 /*!< \brief Receive holding register offset. */
  126. #define TWI_RHR (TWI_BASE + TWI_RHR_OFF) /*!< \brief Receive holding register address. */
  127. /*@}*/
  128. /*! \name TWI Transmit Holding Register */
  129. /*@{*/
  130. #define TWI_THR_OFF 0x00000034 /*!< \brief Transmit holding register offset. */
  131. #define TWI_THR (TWI_BASE + TWI_THR_OFF) /*!< \brief Transmit holding register address. */
  132. /*@}*/
  133. /*@} xgNutArchArmAt91Twi */
  134. #endif /* _ARCH_ARM_AT91_TWI_H_ */