| 1 |
610 |
jeremybenn |
//*****************************************************************************
|
| 2 |
|
|
//
|
| 3 |
|
|
// hw_qei.h - Macros used when accessing the QEI hardware.
|
| 4 |
|
|
//
|
| 5 |
|
|
// Copyright (c) 2005-2008 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 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. You may not combine
|
| 14 |
|
|
// this software with "viral" open-source software in order to form a larger
|
| 15 |
|
|
// program. Any use in violation of the foregoing restrictions may subject
|
| 16 |
|
|
// the user to criminal sanctions under applicable laws, as well as to civil
|
| 17 |
|
|
// liability for the breach of the terms and conditions of this license.
|
| 18 |
|
|
//
|
| 19 |
|
|
// THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
| 20 |
|
|
// OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
| 21 |
|
|
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
| 22 |
|
|
// LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
|
| 23 |
|
|
// CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
| 24 |
|
|
//
|
| 25 |
|
|
// This is part of revision 2523 of the Stellaris Peripheral Driver Library.
|
| 26 |
|
|
//
|
| 27 |
|
|
//*****************************************************************************
|
| 28 |
|
|
|
| 29 |
|
|
#ifndef __HW_QEI_H__
|
| 30 |
|
|
#define __HW_QEI_H__
|
| 31 |
|
|
|
| 32 |
|
|
//*****************************************************************************
|
| 33 |
|
|
//
|
| 34 |
|
|
// The following are defines for the QEI register offsets.
|
| 35 |
|
|
//
|
| 36 |
|
|
//*****************************************************************************
|
| 37 |
|
|
#define QEI_O_CTL 0x00000000 // Configuration and control reg.
|
| 38 |
|
|
#define QEI_O_STAT 0x00000004 // Status register
|
| 39 |
|
|
#define QEI_O_POS 0x00000008 // Current position register
|
| 40 |
|
|
#define QEI_O_MAXPOS 0x0000000C // Maximum position register
|
| 41 |
|
|
#define QEI_O_LOAD 0x00000010 // Velocity timer load register
|
| 42 |
|
|
#define QEI_O_TIME 0x00000014 // Velocity timer register
|
| 43 |
|
|
#define QEI_O_COUNT 0x00000018 // Velocity pulse count register
|
| 44 |
|
|
#define QEI_O_SPEED 0x0000001C // Velocity speed register
|
| 45 |
|
|
#define QEI_O_INTEN 0x00000020 // Interrupt enable register
|
| 46 |
|
|
#define QEI_O_RIS 0x00000024 // Raw interrupt status register
|
| 47 |
|
|
#define QEI_O_ISC 0x00000028 // Interrupt status register
|
| 48 |
|
|
|
| 49 |
|
|
//*****************************************************************************
|
| 50 |
|
|
//
|
| 51 |
|
|
// The following are defines for the bit fields in the QEI_CTL register.
|
| 52 |
|
|
//
|
| 53 |
|
|
//*****************************************************************************
|
| 54 |
|
|
#define QEI_CTL_STALLEN 0x00001000 // Stall enable
|
| 55 |
|
|
#define QEI_CTL_INVI 0x00000800 // Invert Index input
|
| 56 |
|
|
#define QEI_CTL_INVB 0x00000400 // Invert PhB input
|
| 57 |
|
|
#define QEI_CTL_INVA 0x00000200 // Invert PhA input
|
| 58 |
|
|
#define QEI_CTL_VELDIV_M 0x000001C0 // Velocity predivider mask
|
| 59 |
|
|
#define QEI_CTL_VELDIV_1 0x00000000 // Predivide by 1
|
| 60 |
|
|
#define QEI_CTL_VELDIV_2 0x00000040 // Predivide by 2
|
| 61 |
|
|
#define QEI_CTL_VELDIV_4 0x00000080 // Predivide by 4
|
| 62 |
|
|
#define QEI_CTL_VELDIV_8 0x000000C0 // Predivide by 8
|
| 63 |
|
|
#define QEI_CTL_VELDIV_16 0x00000100 // Predivide by 16
|
| 64 |
|
|
#define QEI_CTL_VELDIV_32 0x00000140 // Predivide by 32
|
| 65 |
|
|
#define QEI_CTL_VELDIV_64 0x00000180 // Predivide by 64
|
| 66 |
|
|
#define QEI_CTL_VELDIV_128 0x000001C0 // Predivide by 128
|
| 67 |
|
|
#define QEI_CTL_VELEN 0x00000020 // Velocity enable
|
| 68 |
|
|
#define QEI_CTL_RESMODE 0x00000010 // Position counter reset mode
|
| 69 |
|
|
#define QEI_CTL_CAPMODE 0x00000008 // Edge capture mode
|
| 70 |
|
|
#define QEI_CTL_SIGMODE 0x00000004 // Encoder signaling mode
|
| 71 |
|
|
#define QEI_CTL_SWAP 0x00000002 // Swap input signals
|
| 72 |
|
|
#define QEI_CTL_ENABLE 0x00000001 // QEI enable
|
| 73 |
|
|
|
| 74 |
|
|
//*****************************************************************************
|
| 75 |
|
|
//
|
| 76 |
|
|
// The following are defines for the bit fields in the QEI_STAT register.
|
| 77 |
|
|
//
|
| 78 |
|
|
//*****************************************************************************
|
| 79 |
|
|
#define QEI_STAT_DIRECTION 0x00000002 // Direction of rotation
|
| 80 |
|
|
#define QEI_STAT_ERROR 0x00000001 // Signalling error detected
|
| 81 |
|
|
|
| 82 |
|
|
//*****************************************************************************
|
| 83 |
|
|
//
|
| 84 |
|
|
// The following are defines for the bit fields in the QEI_POS register.
|
| 85 |
|
|
//
|
| 86 |
|
|
//*****************************************************************************
|
| 87 |
|
|
#define QEI_POS_M 0xFFFFFFFF // Current encoder position
|
| 88 |
|
|
#define QEI_POS_S 0
|
| 89 |
|
|
|
| 90 |
|
|
//*****************************************************************************
|
| 91 |
|
|
//
|
| 92 |
|
|
// The following are defines for the bit fields in the QEI_MAXPOS register.
|
| 93 |
|
|
//
|
| 94 |
|
|
//*****************************************************************************
|
| 95 |
|
|
#define QEI_MAXPOS_M 0xFFFFFFFF // Maximum encoder position
|
| 96 |
|
|
#define QEI_MAXPOS_S 0
|
| 97 |
|
|
|
| 98 |
|
|
//*****************************************************************************
|
| 99 |
|
|
//
|
| 100 |
|
|
// The following are defines for the bit fields in the QEI_LOAD register.
|
| 101 |
|
|
//
|
| 102 |
|
|
//*****************************************************************************
|
| 103 |
|
|
#define QEI_LOAD_M 0xFFFFFFFF // Velocity timer load value
|
| 104 |
|
|
#define QEI_LOAD_S 0
|
| 105 |
|
|
|
| 106 |
|
|
//*****************************************************************************
|
| 107 |
|
|
//
|
| 108 |
|
|
// The following are defines for the bit fields in the QEI_TIME register.
|
| 109 |
|
|
//
|
| 110 |
|
|
//*****************************************************************************
|
| 111 |
|
|
#define QEI_TIME_M 0xFFFFFFFF // Velocity timer current value
|
| 112 |
|
|
#define QEI_TIME_S 0
|
| 113 |
|
|
|
| 114 |
|
|
//*****************************************************************************
|
| 115 |
|
|
//
|
| 116 |
|
|
// The following are defines for the bit fields in the QEI_COUNT register.
|
| 117 |
|
|
//
|
| 118 |
|
|
//*****************************************************************************
|
| 119 |
|
|
#define QEI_COUNT_M 0xFFFFFFFF // Encoder running pulse count
|
| 120 |
|
|
#define QEI_COUNT_S 0
|
| 121 |
|
|
|
| 122 |
|
|
//*****************************************************************************
|
| 123 |
|
|
//
|
| 124 |
|
|
// The following are defines for the bit fields in the QEI_SPEED register.
|
| 125 |
|
|
//
|
| 126 |
|
|
//*****************************************************************************
|
| 127 |
|
|
#define QEI_SPEED_M 0xFFFFFFFF // Encoder pulse count
|
| 128 |
|
|
#define QEI_SPEED_S 0
|
| 129 |
|
|
|
| 130 |
|
|
//*****************************************************************************
|
| 131 |
|
|
//
|
| 132 |
|
|
// The following are defines for the bit fields in the QEI_INTEN register.
|
| 133 |
|
|
//
|
| 134 |
|
|
//*****************************************************************************
|
| 135 |
|
|
#define QEI_INTEN_ERROR 0x00000008 // Phase error detected
|
| 136 |
|
|
#define QEI_INTEN_DIR 0x00000004 // Direction change
|
| 137 |
|
|
#define QEI_INTEN_TIMER 0x00000002 // Velocity timer expired
|
| 138 |
|
|
#define QEI_INTEN_INDEX 0x00000001 // Index pulse detected
|
| 139 |
|
|
|
| 140 |
|
|
//*****************************************************************************
|
| 141 |
|
|
//
|
| 142 |
|
|
// The following are defines for the bit fields in the QEI_RIS register.
|
| 143 |
|
|
//
|
| 144 |
|
|
//*****************************************************************************
|
| 145 |
|
|
#define QEI_RIS_ERROR 0x00000008 // Phase error detected
|
| 146 |
|
|
#define QEI_RIS_DIR 0x00000004 // Direction change
|
| 147 |
|
|
#define QEI_RIS_TIMER 0x00000002 // Velocity timer expired
|
| 148 |
|
|
#define QEI_RIS_INDEX 0x00000001 // Index pulse detected
|
| 149 |
|
|
|
| 150 |
|
|
//*****************************************************************************
|
| 151 |
|
|
//
|
| 152 |
|
|
// The following are defines for the bit fields in the QEI_O_ISC register.
|
| 153 |
|
|
//
|
| 154 |
|
|
//*****************************************************************************
|
| 155 |
|
|
#define QEI_ISC_ERROR 0x00000008 // Phase Error Interrupt.
|
| 156 |
|
|
#define QEI_ISC_DIR 0x00000004 // Direction Change Interrupt.
|
| 157 |
|
|
#define QEI_ISC_TIMER 0x00000002 // Velocity Timer Expired
|
| 158 |
|
|
// Interrupt.
|
| 159 |
|
|
#define QEI_ISC_INDEX 0x00000001 // Index Pulse Interrupt.
|
| 160 |
|
|
|
| 161 |
|
|
//*****************************************************************************
|
| 162 |
|
|
//
|
| 163 |
|
|
// The following definitions are deprecated.
|
| 164 |
|
|
//
|
| 165 |
|
|
//*****************************************************************************
|
| 166 |
|
|
#ifndef DEPRECATED
|
| 167 |
|
|
|
| 168 |
|
|
//*****************************************************************************
|
| 169 |
|
|
//
|
| 170 |
|
|
// The following are deprecated defines for the bit fields in the QEI_ISC
|
| 171 |
|
|
// register.
|
| 172 |
|
|
//
|
| 173 |
|
|
//*****************************************************************************
|
| 174 |
|
|
#define QEI_INT_ERROR 0x00000008 // Phase error detected
|
| 175 |
|
|
#define QEI_INT_DIR 0x00000004 // Direction change
|
| 176 |
|
|
#define QEI_INT_TIMER 0x00000002 // Velocity timer expired
|
| 177 |
|
|
#define QEI_INT_INDEX 0x00000001 // Index pulse detected
|
| 178 |
|
|
|
| 179 |
|
|
//*****************************************************************************
|
| 180 |
|
|
//
|
| 181 |
|
|
// The following are deprecated defines for the reset values for the QEI
|
| 182 |
|
|
// registers.
|
| 183 |
|
|
//
|
| 184 |
|
|
//*****************************************************************************
|
| 185 |
|
|
#define QEI_RV_POS 0x00000000 // Current position register
|
| 186 |
|
|
#define QEI_RV_LOAD 0x00000000 // Velocity timer load register
|
| 187 |
|
|
#define QEI_RV_CTL 0x00000000 // Configuration and control reg.
|
| 188 |
|
|
#define QEI_RV_RIS 0x00000000 // Raw interrupt status register
|
| 189 |
|
|
#define QEI_RV_ISC 0x00000000 // Interrupt status register
|
| 190 |
|
|
#define QEI_RV_SPEED 0x00000000 // Velocity speed register
|
| 191 |
|
|
#define QEI_RV_INTEN 0x00000000 // Interrupt enable register
|
| 192 |
|
|
#define QEI_RV_STAT 0x00000000 // Status register
|
| 193 |
|
|
#define QEI_RV_COUNT 0x00000000 // Velocity pulse count register
|
| 194 |
|
|
#define QEI_RV_MAXPOS 0x00000000 // Maximum position register
|
| 195 |
|
|
#define QEI_RV_TIME 0x00000000 // Velocity timer register
|
| 196 |
|
|
|
| 197 |
|
|
#endif
|
| 198 |
|
|
|
| 199 |
|
|
#endif // __HW_QEI_H__
|