1 //*****************************************************************************
\r
3 // qei.h - Prototypes for the Quadrature Encoder Driver.
\r
5 // Copyright (c) 2005-2008 Luminary Micro, Inc. All rights reserved.
\r
7 // Software License Agreement
\r
9 // Luminary Micro, Inc. (LMI) is supplying this software for use solely and
\r
10 // exclusively on LMI's microcontroller products.
\r
12 // The software is owned by LMI and/or its suppliers, and is protected under
\r
13 // applicable copyright laws. All rights are reserved. You may not combine
\r
14 // this software with "viral" open-source software in order to form a larger
\r
15 // program. Any use in violation of the foregoing restrictions may subject
\r
16 // the user to criminal sanctions under applicable laws, as well as to civil
\r
17 // liability for the breach of the terms and conditions of this license.
\r
19 // THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
\r
20 // OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
\r
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
\r
22 // LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
\r
23 // CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
\r
25 // This is part of revision 2523 of the Stellaris Peripheral Driver Library.
\r
27 //*****************************************************************************
\r
32 //*****************************************************************************
\r
34 // If building with a C++ compiler, make all of the definitions in this header
\r
35 // have a C binding.
\r
37 //*****************************************************************************
\r
43 //*****************************************************************************
\r
45 // Values that can be passed to QEIConfigure as the ulConfig paramater.
\r
47 //*****************************************************************************
\r
48 #define QEI_CONFIG_CAPTURE_A 0x00000000 // Count on ChA edges only
\r
49 #define QEI_CONFIG_CAPTURE_A_B 0x00000008 // Count on ChA and ChB edges
\r
50 #define QEI_CONFIG_NO_RESET 0x00000000 // Do not reset on index pulse
\r
51 #define QEI_CONFIG_RESET_IDX 0x00000010 // Reset position on index pulse
\r
52 #define QEI_CONFIG_QUADRATURE 0x00000000 // ChA and ChB are quadrature
\r
53 #define QEI_CONFIG_CLOCK_DIR 0x00000004 // ChA and ChB are clock and dir
\r
54 #define QEI_CONFIG_NO_SWAP 0x00000000 // Do not swap ChA and ChB
\r
55 #define QEI_CONFIG_SWAP 0x00000002 // Swap ChA and ChB
\r
57 //*****************************************************************************
\r
59 // Values that can be passed to QEIVelocityConfigure as the ulPreDiv parameter.
\r
61 //*****************************************************************************
\r
62 #define QEI_VELDIV_1 0x00000000 // Predivide by 1
\r
63 #define QEI_VELDIV_2 0x00000040 // Predivide by 2
\r
64 #define QEI_VELDIV_4 0x00000080 // Predivide by 4
\r
65 #define QEI_VELDIV_8 0x000000C0 // Predivide by 8
\r
66 #define QEI_VELDIV_16 0x00000100 // Predivide by 16
\r
67 #define QEI_VELDIV_32 0x00000140 // Predivide by 32
\r
68 #define QEI_VELDIV_64 0x00000180 // Predivide by 64
\r
69 #define QEI_VELDIV_128 0x000001C0 // Predivide by 128
\r
71 //*****************************************************************************
\r
73 // Values that can be passed to QEIEnableInts, QEIDisableInts, and QEIClearInts
\r
74 // as the ulIntFlags parameter, and returned by QEIGetIntStatus.
\r
76 //*****************************************************************************
\r
77 #define QEI_INTERROR 0x00000008 // Phase error detected
\r
78 #define QEI_INTDIR 0x00000004 // Direction change
\r
79 #define QEI_INTTIMER 0x00000002 // Velocity timer expired
\r
80 #define QEI_INTINDEX 0x00000001 // Index pulse detected
\r
82 //*****************************************************************************
\r
84 // Prototypes for the APIs.
\r
86 //*****************************************************************************
\r
87 extern void QEIEnable(unsigned long ulBase);
\r
88 extern void QEIDisable(unsigned long ulBase);
\r
89 extern void QEIConfigure(unsigned long ulBase, unsigned long ulConfig,
\r
90 unsigned long ulMaxPosition);
\r
91 extern unsigned long QEIPositionGet(unsigned long ulBase);
\r
92 extern void QEIPositionSet(unsigned long ulBase, unsigned long ulPosition);
\r
93 extern long QEIDirectionGet(unsigned long ulBase);
\r
94 extern tBoolean QEIErrorGet(unsigned long ulBase);
\r
95 extern void QEIVelocityEnable(unsigned long ulBase);
\r
96 extern void QEIVelocityDisable(unsigned long ulBase);
\r
97 extern void QEIVelocityConfigure(unsigned long ulBase, unsigned long ulPreDiv,
\r
98 unsigned long ulPeriod);
\r
99 extern unsigned long QEIVelocityGet(unsigned long ulBase);
\r
100 extern void QEIIntRegister(unsigned long ulBase, void (*pfnHandler)(void));
\r
101 extern void QEIIntUnregister(unsigned long ulBase);
\r
102 extern void QEIIntEnable(unsigned long ulBase, unsigned long ulIntFlags);
\r
103 extern void QEIIntDisable(unsigned long ulBase, unsigned long ulIntFlags);
\r
104 extern unsigned long QEIIntStatus(unsigned long ulBase, tBoolean bMasked);
\r
105 extern void QEIIntClear(unsigned long ulBase, unsigned long ulIntFlags);
\r
107 //*****************************************************************************
\r
109 // Mark the end of the C bindings section for C++ compilers.
\r
111 //*****************************************************************************
\r
116 #endif // __QEI_H__
\r