at91_twi.h
Go to the documentation of this file.00001
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073 #ifndef AT91_TWI_H
00074 #define AT91_TWI_H
00075
00076
00081 #define TWI_CR_OFF 0x00000000 ///< Control register offset.
00082 #define TWI_CR (*((reg32_t *)(TWI_BASE + TWI_CR_OFF))) ///< Control register address.
00083 #define TWI_START 0 ///< Send start condition.
00084 #define TWI_STOP 1 ///< Send stop condition.
00085 #define TWI_MSEN 2 ///< Enable master mode.
00086 #define TWI_MSDIS 3 ///< Disable master mode.
00087
00088
00089
00090
00091 #define TWI_SWRST 7 ///< Software reset.
00092
00093
00098 #define TWI_MMR_OFF 0x00000004 ///< Master mode register offset.
00099 #define TWI_MMR (*((reg32_t *)(TWI_BASE + TWI_MMR_OFF))) ///< Master mode register address.
00100 #define TWI_IADRSZ_SHIFT 8 ///< Internal device address size shift.
00101 #define TWI_IADRSZ 0x00000300 ///< Internal device address size mask.
00102 #define TWI_IADRSZ_NONE 0x00000000 ///< No internal device address.
00103 #define TWI_IADRSZ_1BYTE 0x00000100 ///< One byte internal device address.
00104 #define TWI_IADRSZ_2BYTE 0x00000200 ///< Two byte internal device address.
00105 #define TWI_IADRSZ_3BYTE 0x00000300 ///< Three byte internal device address.
00106 #define TWI_MREAD 12 ///< Master read direction.
00107 #define TWI_DADR 0x007F0000 ///< Device address mask.
00108 #define TWI_DADR_SHIFT 16 ///< Device address LSB.
00109
00110
00115 #define TWI_IADR_OFF 0x0000000C ///< Internal address register offset.
00116 #define TWI_IADR (*((reg32_t *)(TWI_BASE + TWI_IADR_OFF))) ///< Internal address register address.
00117 #define TWI_IADR_MASK 0x00FFFFFF ///< Internal address mask.
00118 #define TWI_IADR_SHIFT 0 ///< Internal address LSB.
00119
00120
00125 #define TWI_CWGR_OFF 0x00000010 ///< Clock waveform generator register offset.
00126 #define TWI_CWGR (*((reg32_t *)(TWI_BASE + TWI_CWGR_OFF))) ///< Clock waveform generator register address.
00127 #define TWI_CLDIV 0x000000FF ///< Clock low divider mask.
00128 #define TWI_CLDIV_SHIFT 0 ///< Clock low divider LSB.
00129 #define TWI_CHDIV 0x0000FF00 ///< Clock high divider mask.
00130 #define TWI_CHDIV_SHIFT 8 ///< Clock high divider LSB.
00131 #define TWI_CKDIV 0x00070000 ///< Clock divider mask.
00132 #define TWI_CKDIV_SHIFT 16 ///< Clock divider LSB.
00133
00134
00139 #define TWI_SR_OFF 0x00000020 ///< Status register offset.
00140 #define TWI_SR (*((reg32_t *)(TWI_BASE + TWI_SR_OFF))) ///< Status register address.
00141
00142 #define TWI_IER_OFF 0x00000024 ///< Interrupt enable register offset.
00143 #define TWI_IER (*((reg32_t *)(TWI_BASE + TWI_IER_OFF))) ///< Interrupt enable register address.
00144
00145 #define TWI_IDR_OFF 0x00000028 ///< Interrupt disable register offset.
00146 #define TWI_IDR (*((reg32_t *)(TWI_BASE + TWI_IDR_OFF))) ///< Interrupt disable register address.
00147
00148 #define TWI_IMR_OFF 0x0000002C ///< Interrupt mask register offset.
00149 #define TWI_IMR (*((reg32_t *)(TWI_BASE + TWI_IMR_OFF))) ///< Interrupt mask register address.
00150
00151 #define TWI_TXCOMP 0 ///< Transmission completed.
00152 #define TWI_RXRDY 1 ///< Receive holding register ready.
00153 #define TWI_TXRDY 2 ///< Transmit holding register ready.
00154
00155
00156
00157
00158
00159
00160
00161 #if CPU_ARM_SAM7X
00162 #define TWI_OVRE 6 ///< Overrun error.
00163 #define TWI_UNRE 7 ///< Underrun error.
00164 #endif
00165
00166 #define TWI_NACK 8 ///< Not acknowledged.
00167
00168
00169
00170
00171
00172
00173
00178 #define TWI_RHR_OFF 0x00000030 ///< Receive holding register offset.
00179 #define TWI_RHR (*((reg32_t *)(TWI_BASE + TWI_RHR_OFF))) ///< Receive holding register address.
00180
00181
00186 #define TWI_THR_OFF 0x00000034 ///< Transmit holding register offset.
00187 #define TWI_THR (*((reg32_t *)(TWI_BASE + TWI_THR_OFF))) ///< Transmit holding register address.
00188
00189
00190
00191 #endif