1 |
581 |
jeremybenn |
//*****************************************************************************
|
2 |
|
|
//
|
3 |
|
|
// hw_qei.h - Macros used when accessing the QEI 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_QEI_H__
|
29 |
|
|
#define __HW_QEI_H__
|
30 |
|
|
|
31 |
|
|
//*****************************************************************************
|
32 |
|
|
//
|
33 |
|
|
// The following define the offsets of the QEI registers.
|
34 |
|
|
//
|
35 |
|
|
//*****************************************************************************
|
36 |
|
|
#define QEI_O_CTL 0x00000000 // Configuration and control reg.
|
37 |
|
|
#define QEI_O_STAT 0x00000004 // Status register
|
38 |
|
|
#define QEI_O_POS 0x00000008 // Current position register
|
39 |
|
|
#define QEI_O_MAXPOS 0x0000000C // Maximum position register
|
40 |
|
|
#define QEI_O_LOAD 0x00000010 // Velocity timer load register
|
41 |
|
|
#define QEI_O_TIME 0x00000014 // Velocity timer register
|
42 |
|
|
#define QEI_O_COUNT 0x00000018 // Velocity pulse count register
|
43 |
|
|
#define QEI_O_SPEED 0x0000001C // Velocity speed register
|
44 |
|
|
#define QEI_O_INTEN 0x00000020 // Interrupt enable register
|
45 |
|
|
#define QEI_O_RIS 0x00000024 // Raw interrupt status register
|
46 |
|
|
#define QEI_O_ISC 0x00000028 // Interrupt status register
|
47 |
|
|
|
48 |
|
|
//*****************************************************************************
|
49 |
|
|
//
|
50 |
|
|
// The following define the bit fields in the QEI_CTL register.
|
51 |
|
|
//
|
52 |
|
|
//*****************************************************************************
|
53 |
|
|
#define QEI_CTL_STALLEN 0x00001000 // Stall enable
|
54 |
|
|
#define QEI_CTL_INVI 0x00000800 // Invert Index input
|
55 |
|
|
#define QEI_CTL_INVB 0x00000400 // Invert PhB input
|
56 |
|
|
#define QEI_CTL_INVA 0x00000200 // Invert PhA input
|
57 |
|
|
#define QEI_CTL_VELDIV_M 0x000001C0 // Velocity predivider mask
|
58 |
|
|
#define QEI_CTL_VELDIV_1 0x00000000 // Predivide by 1
|
59 |
|
|
#define QEI_CTL_VELDIV_2 0x00000040 // Predivide by 2
|
60 |
|
|
#define QEI_CTL_VELDIV_4 0x00000080 // Predivide by 4
|
61 |
|
|
#define QEI_CTL_VELDIV_8 0x000000C0 // Predivide by 8
|
62 |
|
|
#define QEI_CTL_VELDIV_16 0x00000100 // Predivide by 16
|
63 |
|
|
#define QEI_CTL_VELDIV_32 0x00000140 // Predivide by 32
|
64 |
|
|
#define QEI_CTL_VELDIV_64 0x00000180 // Predivide by 64
|
65 |
|
|
#define QEI_CTL_VELDIV_128 0x000001C0 // Predivide by 128
|
66 |
|
|
#define QEI_CTL_VELEN 0x00000020 // Velocity enable
|
67 |
|
|
#define QEI_CTL_RESMODE 0x00000010 // Position counter reset mode
|
68 |
|
|
#define QEI_CTL_CAPMODE 0x00000008 // Edge capture mode
|
69 |
|
|
#define QEI_CTL_SIGMODE 0x00000004 // Encoder signaling mode
|
70 |
|
|
#define QEI_CTL_SWAP 0x00000002 // Swap input signals
|
71 |
|
|
#define QEI_CTL_ENABLE 0x00000001 // QEI enable
|
72 |
|
|
|
73 |
|
|
//*****************************************************************************
|
74 |
|
|
//
|
75 |
|
|
// The following define the bit fields in the QEI_STAT register.
|
76 |
|
|
//
|
77 |
|
|
//*****************************************************************************
|
78 |
|
|
#define QEI_STAT_DIRECTION 0x00000002 // Direction of rotation
|
79 |
|
|
#define QEI_STAT_ERROR 0x00000001 // Signalling error detected
|
80 |
|
|
|
81 |
|
|
//*****************************************************************************
|
82 |
|
|
//
|
83 |
|
|
// The following define the bit fields in the QEI_POS register.
|
84 |
|
|
//
|
85 |
|
|
//*****************************************************************************
|
86 |
|
|
#define QEI_POS_M 0xFFFFFFFF // Current encoder position
|
87 |
|
|
#define QEI_POS_S 0
|
88 |
|
|
|
89 |
|
|
//*****************************************************************************
|
90 |
|
|
//
|
91 |
|
|
// The following define the bit fields in the QEI_MAXPOS register.
|
92 |
|
|
//
|
93 |
|
|
//*****************************************************************************
|
94 |
|
|
#define QEI_MAXPOS_M 0xFFFFFFFF // Maximum encoder position
|
95 |
|
|
#define QEI_MAXPOS_S 0
|
96 |
|
|
|
97 |
|
|
//*****************************************************************************
|
98 |
|
|
//
|
99 |
|
|
// The following define the bit fields in the QEI_LOAD register.
|
100 |
|
|
//
|
101 |
|
|
//*****************************************************************************
|
102 |
|
|
#define QEI_LOAD_M 0xFFFFFFFF // Velocity timer load value
|
103 |
|
|
#define QEI_LOAD_S 0
|
104 |
|
|
|
105 |
|
|
//*****************************************************************************
|
106 |
|
|
//
|
107 |
|
|
// The following define the bit fields in the QEI_TIME register.
|
108 |
|
|
//
|
109 |
|
|
//*****************************************************************************
|
110 |
|
|
#define QEI_TIME_M 0xFFFFFFFF // Velocity timer current value
|
111 |
|
|
#define QEI_TIME_S 0
|
112 |
|
|
|
113 |
|
|
//*****************************************************************************
|
114 |
|
|
//
|
115 |
|
|
// The following define the bit fields in the QEI_COUNT register.
|
116 |
|
|
//
|
117 |
|
|
//*****************************************************************************
|
118 |
|
|
#define QEI_COUNT_M 0xFFFFFFFF // Encoder running pulse count
|
119 |
|
|
#define QEI_COUNT_S 0
|
120 |
|
|
|
121 |
|
|
//*****************************************************************************
|
122 |
|
|
//
|
123 |
|
|
// The following define the bit fields in the QEI_SPEED register.
|
124 |
|
|
//
|
125 |
|
|
//*****************************************************************************
|
126 |
|
|
#define QEI_SPEED_M 0xFFFFFFFF // Encoder pulse count
|
127 |
|
|
#define QEI_SPEED_S 0
|
128 |
|
|
|
129 |
|
|
//*****************************************************************************
|
130 |
|
|
//
|
131 |
|
|
// The following define the bit fields in the QEI_INTEN register.
|
132 |
|
|
//
|
133 |
|
|
//*****************************************************************************
|
134 |
|
|
#define QEI_INTEN_ERROR 0x00000008 // Phase error detected
|
135 |
|
|
#define QEI_INTEN_DIR 0x00000004 // Direction change
|
136 |
|
|
#define QEI_INTEN_TIMER 0x00000002 // Velocity timer expired
|
137 |
|
|
#define QEI_INTEN_INDEX 0x00000001 // Index pulse detected
|
138 |
|
|
|
139 |
|
|
//*****************************************************************************
|
140 |
|
|
//
|
141 |
|
|
// The following define the bit fields in the QEI_RIS register.
|
142 |
|
|
//
|
143 |
|
|
//*****************************************************************************
|
144 |
|
|
#define QEI_RIS_ERROR 0x00000008 // Phase error detected
|
145 |
|
|
#define QEI_RIS_DIR 0x00000004 // Direction change
|
146 |
|
|
#define QEI_RIS_TIMER 0x00000002 // Velocity timer expired
|
147 |
|
|
#define QEI_RIS_INDEX 0x00000001 // Index pulse detected
|
148 |
|
|
|
149 |
|
|
//*****************************************************************************
|
150 |
|
|
//
|
151 |
|
|
// The following define the bit fields in the QEI_ISC register.
|
152 |
|
|
//
|
153 |
|
|
//*****************************************************************************
|
154 |
|
|
#define QEI_INT_ERROR 0x00000008 // Phase error detected
|
155 |
|
|
#define QEI_INT_DIR 0x00000004 // Direction change
|
156 |
|
|
#define QEI_INT_TIMER 0x00000002 // Velocity timer expired
|
157 |
|
|
#define QEI_INT_INDEX 0x00000001 // Index pulse detected
|
158 |
|
|
|
159 |
|
|
//*****************************************************************************
|
160 |
|
|
//
|
161 |
|
|
// The following define the reset values for the QEI registers.
|
162 |
|
|
//
|
163 |
|
|
//*****************************************************************************
|
164 |
|
|
#define QEI_RV_CTL 0x00000000 // Configuration and control reg.
|
165 |
|
|
#define QEI_RV_STAT 0x00000000 // Status register
|
166 |
|
|
#define QEI_RV_POS 0x00000000 // Current position register
|
167 |
|
|
#define QEI_RV_MAXPOS 0x00000000 // Maximum position register
|
168 |
|
|
#define QEI_RV_LOAD 0x00000000 // Velocity timer load register
|
169 |
|
|
#define QEI_RV_TIME 0x00000000 // Velocity timer register
|
170 |
|
|
#define QEI_RV_COUNT 0x00000000 // Velocity pulse count register
|
171 |
|
|
#define QEI_RV_SPEED 0x00000000 // Velocity speed register
|
172 |
|
|
#define QEI_RV_INTEN 0x00000000 // Interrupt enable register
|
173 |
|
|
#define QEI_RV_RIS 0x00000000 // Raw interrupt status register
|
174 |
|
|
#define QEI_RV_ISC 0x00000000 // Interrupt status register
|
175 |
|
|
|
176 |
|
|
#endif // __HW_QEI_H__
|