1 |
581 |
jeremybenn |
//*****************************************************************************
|
2 |
|
|
//
|
3 |
|
|
// hw_i2c.h - Macros used when accessing the I2C master and slave hardware.
|
4 |
|
|
//
|
5 |
|
|
// Copyright (c) 2005,2006 Luminary Micro, Inc. All rights reserved.
|
6 |
|
|
//
|
7 |
|
|
// Software License Agreement
|
8 |
|
|
//
|
9 |
|
|
// Luminary Micro, Inc. (LMI) is supplying this software for use solely and
|
10 |
|
|
// exclusively on LMI's Stellaris Family of microcontroller products.
|
11 |
|
|
//
|
12 |
|
|
// The software is owned by LMI and/or its suppliers, and is protected under
|
13 |
|
|
// applicable copyright laws. All rights are reserved. Any use in violation
|
14 |
|
|
// of the foregoing restrictions may subject the user to criminal sanctions
|
15 |
|
|
// under applicable laws, as well as to civil liability for the breach of the
|
16 |
|
|
// terms and conditions of this license.
|
17 |
|
|
//
|
18 |
|
|
// THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
19 |
|
|
// OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
20 |
|
|
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
21 |
|
|
// LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
|
22 |
|
|
// CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
23 |
|
|
//
|
24 |
|
|
// This is part of revision 816 of the Stellaris Driver Library.
|
25 |
|
|
//
|
26 |
|
|
//*****************************************************************************
|
27 |
|
|
|
28 |
|
|
#ifndef __HW_I2C_H__
|
29 |
|
|
#define __HW_I2C_H__
|
30 |
|
|
|
31 |
|
|
//*****************************************************************************
|
32 |
|
|
//
|
33 |
|
|
// The following defines the offset between the I2C master and slave registers.
|
34 |
|
|
//
|
35 |
|
|
//*****************************************************************************
|
36 |
|
|
#define I2C_O_SLAVE 0x00000800 // Offset from master to slave
|
37 |
|
|
|
38 |
|
|
//*****************************************************************************
|
39 |
|
|
//
|
40 |
|
|
// The following define the offsets of the I2C master registers.
|
41 |
|
|
//
|
42 |
|
|
//*****************************************************************************
|
43 |
|
|
#define I2C_MASTER_O_SA 0x00000000 // Slave address register
|
44 |
|
|
#define I2C_MASTER_O_CS 0x00000004 // Control and Status register
|
45 |
|
|
#define I2C_MASTER_O_DR 0x00000008 // Data register
|
46 |
|
|
#define I2C_MASTER_O_TPR 0x0000000C // Timer period register
|
47 |
|
|
#define I2C_MASTER_O_IMR 0x00000010 // Interrupt mask register
|
48 |
|
|
#define I2C_MASTER_O_RIS 0x00000014 // Raw interrupt status register
|
49 |
|
|
#define I2C_MASTER_O_MIS 0x00000018 // Masked interrupt status reg
|
50 |
|
|
#define I2C_MASTER_O_MICR 0x0000001c // Interrupt clear register
|
51 |
|
|
#define I2C_MASTER_O_CR 0x00000020 // Configuration register
|
52 |
|
|
|
53 |
|
|
//*****************************************************************************
|
54 |
|
|
//
|
55 |
|
|
// The following define the offsets of the I2C slave registers.
|
56 |
|
|
//
|
57 |
|
|
//*****************************************************************************
|
58 |
|
|
#define I2C_SLAVE_O_OAR 0x00000000 // Own address register
|
59 |
|
|
#define I2C_SLAVE_O_CSR 0x00000004 // Control/Status register
|
60 |
|
|
#define I2C_SLAVE_O_DR 0x00000008 // Data register
|
61 |
|
|
#define I2C_SLAVE_O_IM 0x0000000C // Interrupt mask register
|
62 |
|
|
#define I2C_SLAVE_O_RIS 0x00000010 // Raw interrupt status register
|
63 |
|
|
#define I2C_SLAVE_O_MIS 0x00000014 // Masked interrupt status reg
|
64 |
|
|
#define I2C_SLAVE_O_SICR 0x00000018 // Interrupt clear register
|
65 |
|
|
|
66 |
|
|
//*****************************************************************************
|
67 |
|
|
//
|
68 |
|
|
// The followng define the bit fields in the I2C master slave address register.
|
69 |
|
|
//
|
70 |
|
|
//*****************************************************************************
|
71 |
|
|
#define I2C_MASTER_SA_SA_MASK 0x000000FE // Slave address
|
72 |
|
|
#define I2C_MASTER_SA_RS 0x00000001 // Receive/send
|
73 |
|
|
#define I2C_MASTER_SA_SA_SHIFT 1
|
74 |
|
|
|
75 |
|
|
//*****************************************************************************
|
76 |
|
|
//
|
77 |
|
|
// The following define the bit fields in the I2C Master Control and Status
|
78 |
|
|
// register.
|
79 |
|
|
//
|
80 |
|
|
//*****************************************************************************
|
81 |
|
|
#define I2C_MASTER_CS_ACK 0x00000008 // Acknowlegde
|
82 |
|
|
#define I2C_MASTER_CS_STOP 0x00000004 // Stop
|
83 |
|
|
#define I2C_MASTER_CS_START 0x00000002 // Start
|
84 |
|
|
#define I2C_MASTER_CS_RUN 0x00000001 // Run
|
85 |
|
|
#define I2C_MASTER_CS_BUS_BUSY 0x00000040 // Bus busy
|
86 |
|
|
#define I2C_MASTER_CS_IDLE 0x00000020 // Idle
|
87 |
|
|
#define I2C_MASTER_CS_ARB_LOST 0x00000010 // Lost arbitration
|
88 |
|
|
#define I2C_MASTER_CS_DATA_ACK 0x00000008 // Data byte not acknowledged
|
89 |
|
|
#define I2C_MASTER_CS_ADDR_ACK 0x00000004 // Address byte not acknowledged
|
90 |
|
|
#define I2C_MASTER_CS_ERROR 0x00000002 // Error occurred
|
91 |
|
|
#define I2C_MASTER_CS_BUSY 0x00000001 // Controller is TX/RX data
|
92 |
|
|
#define I2C_MASTER_CS_ERR_MASK 0x0000001C
|
93 |
|
|
|
94 |
|
|
//*****************************************************************************
|
95 |
|
|
//
|
96 |
|
|
// The following define values used in determining the contents of the I2C
|
97 |
|
|
// Master Timer Period register.
|
98 |
|
|
//
|
99 |
|
|
//*****************************************************************************
|
100 |
|
|
#define I2C_MASTER_TPR_SCL_HP 0x00000004 // SCL high period
|
101 |
|
|
#define I2C_MASTER_TPR_SCL_LP 0x00000006 // SCL low period
|
102 |
|
|
#define I2C_MASTER_TPR_SCL (I2C_MASTER_TPR_SCL_HP + I2C_MASTER_TPR_SCL_LP)
|
103 |
|
|
#define I2C_SCL_STANDARD 100000 // SCL standard frequency
|
104 |
|
|
#define I2C_SCL_FAST 400000 // SCL fast frequency
|
105 |
|
|
|
106 |
|
|
//*****************************************************************************
|
107 |
|
|
//
|
108 |
|
|
// The following define the bit fields in the I2C Master Interrupt Mask
|
109 |
|
|
// register.
|
110 |
|
|
//
|
111 |
|
|
//*****************************************************************************
|
112 |
|
|
#define I2C_MASTER_IMR_IM 0x00000001 // Master interrupt mask
|
113 |
|
|
|
114 |
|
|
//*****************************************************************************
|
115 |
|
|
//
|
116 |
|
|
// The following define the bit fields in the I2C Master Raw Interrupt Status
|
117 |
|
|
// register.
|
118 |
|
|
//
|
119 |
|
|
//*****************************************************************************
|
120 |
|
|
#define I2C_MASTER_RIS_RIS 0x00000001 // Master raw interrupt status
|
121 |
|
|
|
122 |
|
|
//*****************************************************************************
|
123 |
|
|
//
|
124 |
|
|
// The following define the bit fields in the I2C Master Masked Interrupt
|
125 |
|
|
// Status register.
|
126 |
|
|
//
|
127 |
|
|
//*****************************************************************************
|
128 |
|
|
#define I2C_MASTER_MIS_MIS 0x00000001 // Master masked interrupt status
|
129 |
|
|
|
130 |
|
|
//*****************************************************************************
|
131 |
|
|
//
|
132 |
|
|
// The following define the bit fields in the I2C Master Interrupt Clear
|
133 |
|
|
// register.
|
134 |
|
|
//
|
135 |
|
|
//*****************************************************************************
|
136 |
|
|
#define I2C_MASTER_MICR_IC 0x00000001 // Master interrupt clear
|
137 |
|
|
|
138 |
|
|
//*****************************************************************************
|
139 |
|
|
//
|
140 |
|
|
// The following define the bit fields in the I2C Master Configuration
|
141 |
|
|
// register.
|
142 |
|
|
//
|
143 |
|
|
//*****************************************************************************
|
144 |
|
|
#define I2C_MASTER_CR_SFE 0x00000020 // Slave function enable
|
145 |
|
|
#define I2C_MASTER_CR_MFE 0x00000010 // Master function enable
|
146 |
|
|
#define I2C_MASTER_CR_LPBK 0x00000001 // Loopback enable
|
147 |
|
|
|
148 |
|
|
//*****************************************************************************
|
149 |
|
|
//
|
150 |
|
|
// The following define the bit fields in the I2C Slave Own Address register.
|
151 |
|
|
//
|
152 |
|
|
//*****************************************************************************
|
153 |
|
|
#define I2C_SLAVE_SOAR_OAR_MASK 0x0000007F // Slave address
|
154 |
|
|
|
155 |
|
|
//*****************************************************************************
|
156 |
|
|
//
|
157 |
|
|
// The following define the bit fields in the I2C Slave Control/Status
|
158 |
|
|
// register.
|
159 |
|
|
//
|
160 |
|
|
//*****************************************************************************
|
161 |
|
|
#define I2C_SLAVE_CSR_DA 0x00000001 // Enable the device
|
162 |
|
|
#define I2C_SLAVE_CSR_TREQ 0x00000002 // Transmit request received
|
163 |
|
|
#define I2C_SLAVE_CSR_RREQ 0x00000001 // Receive data from I2C master
|
164 |
|
|
|
165 |
|
|
//*****************************************************************************
|
166 |
|
|
//
|
167 |
|
|
// The following define the bit fields in the I2C Slave Interrupt Mask
|
168 |
|
|
// register.
|
169 |
|
|
//
|
170 |
|
|
//*****************************************************************************
|
171 |
|
|
#define I2C_SLAVE_IMR_IM 0x00000001 // Slave interrupt mask
|
172 |
|
|
|
173 |
|
|
//*****************************************************************************
|
174 |
|
|
//
|
175 |
|
|
// The following define the bit fields in the I2C Slave Raw Interrupt Status
|
176 |
|
|
// register.
|
177 |
|
|
//
|
178 |
|
|
//*****************************************************************************
|
179 |
|
|
#define I2C_SLAVE_RIS_RIS 0x00000001 // Slave raw interrupt status
|
180 |
|
|
|
181 |
|
|
//*****************************************************************************
|
182 |
|
|
//
|
183 |
|
|
// The following define the bit fields in the I2C Slave Masked Interrupt
|
184 |
|
|
// Status register.
|
185 |
|
|
//
|
186 |
|
|
//*****************************************************************************
|
187 |
|
|
#define I2C_SLAVE_MIS_MIS 0x00000001 // Slave masked interrupt status
|
188 |
|
|
|
189 |
|
|
//*****************************************************************************
|
190 |
|
|
//
|
191 |
|
|
// The following define the bit fields in the I2C Slave Interrupt Clear
|
192 |
|
|
// register.
|
193 |
|
|
//
|
194 |
|
|
//*****************************************************************************
|
195 |
|
|
#define I2C_SLAVE_SICR_IC 0x00000001 // Slave interrupt clear
|
196 |
|
|
|
197 |
|
|
#endif // __HW_I2C_H__
|