at91_twi.h

Go to the documentation of this file.
00001 
00041 /*
00042  * Copyright (C) 2006 by egnite Software GmbH. All rights reserved.
00043  *
00044  * Redistribution and use in source and binary forms, with or without
00045  * modification, are permitted provided that the following conditions
00046  * are met:
00047  *
00048  * 1. Redistributions of source code must retain the above copyright
00049  *    notice, this list of conditions and the following disclaimer.
00050  * 2. Redistributions in binary form must reproduce the above copyright
00051  *    notice, this list of conditions and the following disclaimer in the
00052  *    documentation and/or other materials provided with the distribution.
00053  * 3. Neither the name of the copyright holders nor the names of
00054  *    contributors may be used to endorse or promote products derived
00055  *    from this software without specific prior written permission.
00056  *
00057  * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
00058  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00059  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00060  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
00061  * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00062  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00063  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00064  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
00065  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00066  * OR TORT (*((reg32_t *)(INCLUDING NEGLIGENCE OR OTHERWISE))) ARISING IN ANY WAY OUT OF
00067  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00068  * SUCH DAMAGE.
00069  *
00070  * For additional information see http://www.ethernut.de/
00071  */
00072 
00073 #ifndef AT91_TWI_H
00074 #define AT91_TWI_H
00075 
00076 
00081 #define TWI_CR_OFF              0x00000000      
00082 #define TWI_CR      (*((reg32_t *)(TWI_BASE + TWI_CR_OFF)))     
00083 #define TWI_START                        0      
00084 #define TWI_STOP                         1      
00085 #define TWI_MSEN                         2      
00086 #define TWI_MSDIS                        3      
00087 /*
00088 #define TWI_SVEN                         4      ///< Enable slave mode.
00089 #define TWI_SVDIS                        5      ///< Disable slave mode.
00090 */
00091 #define TWI_SWRST                        7      
00092 /*\}*/
00093 
00098 #define TWI_MMR_OFF             0x00000004      
00099 #define TWI_MMR     (*((reg32_t *)(TWI_BASE + TWI_MMR_OFF)))    
00100 #define TWI_IADRSZ_SHIFT                 8      
00101 #define TWI_IADRSZ              0x00000300      
00102 #define TWI_IADRSZ_NONE         0x00000000      
00103 #define TWI_IADRSZ_1BYTE        0x00000100      
00104 #define TWI_IADRSZ_2BYTE        0x00000200      
00105 #define TWI_IADRSZ_3BYTE        0x00000300      
00106 #define TWI_MREAD                       12      
00107 #define TWI_DADR                0x007F0000      
00108 #define TWI_DADR_SHIFT                  16      
00109 /*\}*/
00110 
00115 #define TWI_IADR_OFF           0x0000000C       
00116 #define TWI_IADR   (*((reg32_t *)(TWI_BASE + TWI_IADR_OFF)))  
00117 #define TWI_IADR_MASK           0x00FFFFFF      
00118 #define TWI_IADR_SHIFT                   0      
00119 /*\}*/
00120 
00125 #define TWI_CWGR_OFF             0x00000010     
00126 #define TWI_CWGR    (*((reg32_t *)(TWI_BASE + TWI_CWGR_OFF)))   
00127 #define TWI_CLDIV                0x000000FF     
00128 #define TWI_CLDIV_SHIFT                   0     
00129 #define TWI_CHDIV                0x0000FF00     
00130 #define TWI_CHDIV_SHIFT                   8     
00131 #define TWI_CKDIV                0x00070000     
00132 #define TWI_CKDIV_SHIFT                  16     
00133 /*\}*/
00134 
00139 #define TWI_SR_OFF              0x00000020      
00140 #define TWI_SR      (*((reg32_t *)(TWI_BASE + TWI_SR_OFF)))     
00141 
00142 #define TWI_IER_OFF             0x00000024      
00143 #define TWI_IER     (*((reg32_t *)(TWI_BASE + TWI_IER_OFF)))    
00144 
00145 #define TWI_IDR_OFF             0x00000028      
00146 #define TWI_IDR     (*((reg32_t *)(TWI_BASE + TWI_IDR_OFF)))    
00147 
00148 #define TWI_IMR_OFF             0x0000002C      
00149 #define TWI_IMR     (*((reg32_t *)(TWI_BASE + TWI_IMR_OFF)))    
00150 
00151 #define TWI_TXCOMP                       0      
00152 #define TWI_RXRDY                        1      
00153 #define TWI_TXRDY                        2      
00154 
00155 /*
00156 #define TWI_SVREAD              0x00000008      ///< Slave read.
00157 #define TWI_SVACC               0x00000010      ///< Slave access.
00158 #define TWI_GACC                0x00000020      ///< General call access.
00159 */
00160 
00161 #if CPU_ARM_AT91SAM7X256 || CPU_ARM_AT91SAM7X128
00162 #define TWI_OVRE                         6      
00163 #define TWI_UNRE                         7      
00164 #endif
00165 
00166 #define TWI_NACK                         8      
00167 /*
00168 #define TWI_ARBLST              0x00000200      ///< Arbitration lost.
00169 #define TWI_SCLWS               0x00000400      ///< Clock wait state.
00170 #define TWI_EOSACC              0x00000800      ///< End of slave access.
00171 */
00172 /*\}*/
00173 
00178 #define TWI_RHR_OFF             0x00000030      
00179 #define TWI_RHR     (*((reg32_t *)(TWI_BASE + TWI_RHR_OFF)))    
00180 /*\}*/
00181 
00186 #define TWI_THR_OFF             0x00000034      
00187 #define TWI_THR     (*((reg32_t *)(TWI_BASE + TWI_THR_OFF)))    
00188 /*\}*/
00189 
00190 
00191 #endif /* AT91_TWI_H */