1 //*****************************************************************************
2 //
3 // hw_qei.h - Macros used when accessing the QEI hardware.
4 //
5 // Copyright (c) 2005-2011 Texas Instruments Incorporated.  All rights reserved.
6 // Software License Agreement
7 //
8 // Texas Instruments (TI) is supplying this software for use solely and
9 // exclusively on TI's microcontroller products. The software is owned by
10 // TI and/or its suppliers, and is protected under applicable copyright
11 // laws. You may not combine this software with "viral" open-source
12 // software in order to form a larger program.
13 //
14 // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
15 // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
16 // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17 // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
18 // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
19 // DAMAGES, FOR ANY REASON WHATSOEVER.
20 //
21 // This is part of revision 8264 of the Stellaris Firmware Development Package.
22 //
23 //*****************************************************************************
24 
25 #ifndef __HW_QEI_H__
26 #define __HW_QEI_H__
27 
28 //*****************************************************************************
29 //
30 // The following are defines for the QEI register offsets.
31 //
32 //*****************************************************************************
33 #define QEI_O_CTL               0x00000000  // QEI Control
34 #define QEI_O_STAT              0x00000004  // QEI Status
35 #define QEI_O_POS               0x00000008  // QEI Position
36 #define QEI_O_MAXPOS            0x0000000C  // QEI Maximum Position
37 #define QEI_O_LOAD              0x00000010  // QEI Timer Load
38 #define QEI_O_TIME              0x00000014  // QEI Timer
39 #define QEI_O_COUNT             0x00000018  // QEI Velocity Counter
40 #define QEI_O_SPEED             0x0000001C  // QEI Velocity
41 #define QEI_O_INTEN             0x00000020  // QEI Interrupt Enable
42 #define QEI_O_RIS               0x00000024  // QEI Raw Interrupt Status
43 #define QEI_O_ISC               0x00000028  // QEI Interrupt Status and Clear
44 
45 //*****************************************************************************
46 //
47 // The following are defines for the bit fields in the QEI_O_CTL register.
48 //
49 //*****************************************************************************
50 #define QEI_CTL_FILTCNT_M       0x000F0000  // Input Filter Prescale Count
51 #define QEI_CTL_FILTEN          0x00002000  // Enable Input Filter
52 #define QEI_CTL_STALLEN         0x00001000  // Stall QEI
53 #define QEI_CTL_INVI            0x00000800  // Invert Index Pulse
54 #define QEI_CTL_INVB            0x00000400  // Invert PhB
55 #define QEI_CTL_INVA            0x00000200  // Invert PhA
56 #define QEI_CTL_VELDIV_M        0x000001C0  // Predivide Velocity
57 #define QEI_CTL_VELDIV_1        0x00000000  // QEI clock /1
58 #define QEI_CTL_VELDIV_2        0x00000040  // QEI clock /2
59 #define QEI_CTL_VELDIV_4        0x00000080  // QEI clock /4
60 #define QEI_CTL_VELDIV_8        0x000000C0  // QEI clock /8
61 #define QEI_CTL_VELDIV_16       0x00000100  // QEI clock /16
62 #define QEI_CTL_VELDIV_32       0x00000140  // QEI clock /32
63 #define QEI_CTL_VELDIV_64       0x00000180  // QEI clock /64
64 #define QEI_CTL_VELDIV_128      0x000001C0  // QEI clock /128
65 #define QEI_CTL_VELEN           0x00000020  // Capture Velocity
66 #define QEI_CTL_RESMODE         0x00000010  // Reset Mode
67 #define QEI_CTL_CAPMODE         0x00000008  // Capture Mode
68 #define QEI_CTL_SIGMODE         0x00000004  // Signal Mode
69 #define QEI_CTL_SWAP            0x00000002  // Swap Signals
70 #define QEI_CTL_ENABLE          0x00000001  // Enable QEI
71 #define QEI_CTL_FILTCNT_S       16
72 
73 //*****************************************************************************
74 //
75 // The following are defines for the bit fields in the QEI_O_STAT register.
76 //
77 //*****************************************************************************
78 #define QEI_STAT_DIRECTION      0x00000002  // Direction of Rotation
79 #define QEI_STAT_ERROR          0x00000001  // Error Detected
80 
81 //*****************************************************************************
82 //
83 // The following are defines for the bit fields in the QEI_O_POS register.
84 //
85 //*****************************************************************************
86 #define QEI_POS_M               0xFFFFFFFF  // Current Position Integrator
87                                             // Value
88 #define QEI_POS_S               0
89 
90 //*****************************************************************************
91 //
92 // The following are defines for the bit fields in the QEI_O_MAXPOS register.
93 //
94 //*****************************************************************************
95 #define QEI_MAXPOS_M            0xFFFFFFFF  // Maximum Position Integrator
96                                             // Value
97 #define QEI_MAXPOS_S            0
98 
99 //*****************************************************************************
100 //
101 // The following are defines for the bit fields in the QEI_O_LOAD register.
102 //
103 //*****************************************************************************
104 #define QEI_LOAD_M              0xFFFFFFFF  // Velocity Timer Load Value
105 #define QEI_LOAD_S              0
106 
107 //*****************************************************************************
108 //
109 // The following are defines for the bit fields in the QEI_O_TIME register.
110 //
111 //*****************************************************************************
112 #define QEI_TIME_M              0xFFFFFFFF  // Velocity Timer Current Value
113 #define QEI_TIME_S              0
114 
115 //*****************************************************************************
116 //
117 // The following are defines for the bit fields in the QEI_O_COUNT register.
118 //
119 //*****************************************************************************
120 #define QEI_COUNT_M             0xFFFFFFFF  // Velocity Pulse Count
121 #define QEI_COUNT_S             0
122 
123 //*****************************************************************************
124 //
125 // The following are defines for the bit fields in the QEI_O_SPEED register.
126 //
127 //*****************************************************************************
128 #define QEI_SPEED_M             0xFFFFFFFF  // Velocity
129 #define QEI_SPEED_S             0
130 
131 //*****************************************************************************
132 //
133 // The following are defines for the bit fields in the QEI_O_INTEN register.
134 //
135 //*****************************************************************************
136 #define QEI_INTEN_ERROR         0x00000008  // Phase Error Interrupt Enable
137 #define QEI_INTEN_DIR           0x00000004  // Direction Change Interrupt
138                                             // Enable
139 #define QEI_INTEN_TIMER         0x00000002  // Timer Expires Interrupt Enable
140 #define QEI_INTEN_INDEX         0x00000001  // Index Pulse Detected Interrupt
141                                             // Enable
142 
143 //*****************************************************************************
144 //
145 // The following are defines for the bit fields in the QEI_O_RIS register.
146 //
147 //*****************************************************************************
148 #define QEI_RIS_ERROR           0x00000008  // Phase Error Detected
149 #define QEI_RIS_DIR             0x00000004  // Direction Change Detected
150 #define QEI_RIS_TIMER           0x00000002  // Velocity Timer Expired
151 #define QEI_RIS_INDEX           0x00000001  // Index Pulse Asserted
152 
153 //*****************************************************************************
154 //
155 // The following are defines for the bit fields in the QEI_O_ISC register.
156 //
157 //*****************************************************************************
158 #define QEI_ISC_ERROR           0x00000008  // Phase Error Interrupt
159 #define QEI_ISC_DIR             0x00000004  // Direction Change Interrupt
160 #define QEI_ISC_TIMER           0x00000002  // Velocity Timer Expired Interrupt
161 #define QEI_ISC_INDEX           0x00000001  // Index Pulse Interrupt
162 
163 //*****************************************************************************
164 //
165 // The following definitions are deprecated.
166 //
167 //*****************************************************************************
168 #ifndef DEPRECATED
169 
170 //*****************************************************************************
171 //
172 // The following are deprecated defines for the bit fields in the QEI_ISC
173 // register.
174 //
175 //*****************************************************************************
176 #define QEI_INT_ERROR           0x00000008  // Phase error detected
177 #define QEI_INT_DIR             0x00000004  // Direction change
178 #define QEI_INT_TIMER           0x00000002  // Velocity timer expired
179 #define QEI_INT_INDEX           0x00000001  // Index pulse detected
180 
181 //*****************************************************************************
182 //
183 // The following are deprecated defines for the reset values for the QEI
184 // registers.
185 //
186 //*****************************************************************************
187 #define QEI_RV_POS              0x00000000  // Current position register
188 #define QEI_RV_LOAD             0x00000000  // Velocity timer load register
189 #define QEI_RV_CTL              0x00000000  // Configuration and control reg
190 #define QEI_RV_RIS              0x00000000  // Raw interrupt status register
191 #define QEI_RV_ISC              0x00000000  // Interrupt status register
192 #define QEI_RV_SPEED            0x00000000  // Velocity speed register
193 #define QEI_RV_INTEN            0x00000000  // Interrupt enable register
194 #define QEI_RV_STAT             0x00000000  // Status register
195 #define QEI_RV_COUNT            0x00000000  // Velocity pulse count register
196 #define QEI_RV_MAXPOS           0x00000000  // Maximum position register
197 #define QEI_RV_TIME             0x00000000  // Velocity timer register
198 
199 #endif
200 
201 #endif // __HW_QEI_H__
202