collab/mm20

git clone https://git.julia.blue/collab/mm20

Allen Jiangadded skeleton for wall sensor0548bd1

firmware
7.6 KiB156 linesraw
1#include <stdbool.h>
2#include <stdint.h>
3//*****************************************************************************
4//
5// qei.h - Prototypes for the Quadrature Encoder Driver.
6//
7// Copyright (c) 2005-2017 Texas Instruments Incorporated.  All rights reserved.
8// Software License Agreement
9// 
10//   Redistribution and use in source and binary forms, with or without
11//   modification, are permitted provided that the following conditions
12//   are met:
13// 
14//   Redistributions of source code must retain the above copyright
15//   notice, this list of conditions and the following disclaimer.
16// 
17//   Redistributions in binary form must reproduce the above copyright
18//   notice, this list of conditions and the following disclaimer in the
19//   documentation and/or other materials provided with the  
20//   distribution.
21// 
22//   Neither the name of Texas Instruments Incorporated nor the names of
23//   its contributors may be used to endorse or promote products derived
24//   from this software without specific prior written permission.
25// 
26// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37// 
38// This is part of revision 2.1.4.178 of the Tiva Peripheral Driver Library.
39//
40//*****************************************************************************
41
42#ifndef __DRIVERLIB_QEI_H__
43#define __DRIVERLIB_QEI_H__
44
45//*****************************************************************************
46//
47// If building with a C++ compiler, make all of the definitions in this header
48// have a C binding.
49//
50//*****************************************************************************
51#ifdef __cplusplus
52extern "C"
53{
54#endif
55
56//*****************************************************************************
57//
58// Values that can be passed to QEIConfigure as the ui32Config paramater.
59//
60//*****************************************************************************
61#define QEI_CONFIG_CAPTURE_A    0x00000000  // Count on ChA edges only
62#define QEI_CONFIG_CAPTURE_A_B  0x00000008  // Count on ChA and ChB edges
63#define QEI_CONFIG_NO_RESET     0x00000000  // Do not reset on index pulse
64#define QEI_CONFIG_RESET_IDX    0x00000010  // Reset position on index pulse
65#define QEI_CONFIG_QUADRATURE   0x00000000  // ChA and ChB are quadrature
66#define QEI_CONFIG_CLOCK_DIR    0x00000004  // ChA and ChB are clock and dir
67#define QEI_CONFIG_NO_SWAP      0x00000000  // Do not swap ChA and ChB
68#define QEI_CONFIG_SWAP         0x00000002  // Swap ChA and ChB
69
70//*****************************************************************************
71//
72// Values that can be passed to QEIFilterConfigure as the ui32PreDiv
73// parameter.
74//
75//*****************************************************************************
76#define QEI_FILTCNT_2           0x00000000  // Filter Count of 2 System Clocks
77#define QEI_FILTCNT_3           0x00010000  // Filter Count of 3 System Clocks
78#define QEI_FILTCNT_4           0x00020000  // Filter Count of 4 System Clocks
79#define QEI_FILTCNT_5           0x00030000  // Filter Count of 5 System Clocks
80#define QEI_FILTCNT_6           0x00040000  // Filter Count of 6 System Clocks
81#define QEI_FILTCNT_7           0x00050000  // Filter Count of 7 System Clocks
82#define QEI_FILTCNT_8           0x00060000  // Filter Count of 8 System Clocks
83#define QEI_FILTCNT_9           0x00070000  // Filter Count of 9 System Clocks
84#define QEI_FILTCNT_10          0x00080000  // Filter Count of 10 System Clocks
85#define QEI_FILTCNT_11          0x00090000  // Filter Count of 11 System Clocks
86#define QEI_FILTCNT_12          0x000A0000  // Filter Count of 12 System Clocks
87#define QEI_FILTCNT_13          0x000B0000  // Filter Count of 13 System Clocks
88#define QEI_FILTCNT_14          0x000C0000  // Filter Count of 14 System Clocks
89#define QEI_FILTCNT_15          0x000D0000  // Filter Count of 15 System Clocks
90#define QEI_FILTCNT_16          0x000E0000  // Filter Count of 16 System Clocks
91#define QEI_FILTCNT_17          0x000F0000  // Filter Count of 17 System Clocks
92
93//*****************************************************************************
94//
95// Values that can be passed to QEIVelocityConfigure as the ui32PreDiv
96// parameter.
97//
98//*****************************************************************************
99#define QEI_VELDIV_1            0x00000000  // Predivide by 1
100#define QEI_VELDIV_2            0x00000040  // Predivide by 2
101#define QEI_VELDIV_4            0x00000080  // Predivide by 4
102#define QEI_VELDIV_8            0x000000C0  // Predivide by 8
103#define QEI_VELDIV_16           0x00000100  // Predivide by 16
104#define QEI_VELDIV_32           0x00000140  // Predivide by 32
105#define QEI_VELDIV_64           0x00000180  // Predivide by 64
106#define QEI_VELDIV_128          0x000001C0  // Predivide by 128
107
108//*****************************************************************************
109//
110// Values that can be passed to QEIEnableInts, QEIDisableInts, and QEIClearInts
111// as the ui32IntFlags parameter, and returned by QEIGetIntStatus.
112//
113//*****************************************************************************
114#define QEI_INTERROR            0x00000008  // Phase error detected
115#define QEI_INTDIR              0x00000004  // Direction change
116#define QEI_INTTIMER            0x00000002  // Velocity timer expired
117#define QEI_INTINDEX            0x00000001  // Index pulse detected
118
119//*****************************************************************************
120//
121// Prototypes for the APIs.
122//
123//*****************************************************************************
124extern void QEIEnable(uint32_t ui32Base);
125extern void QEIDisable(uint32_t ui32Base);
126extern void QEIConfigure(uint32_t ui32Base, uint32_t ui32Config,
127                         uint32_t ui32MaxPosition);
128extern uint32_t QEIPositionGet(uint32_t ui32Base);
129extern void QEIPositionSet(uint32_t ui32Base, uint32_t ui32Position);
130extern int32_t QEIDirectionGet(uint32_t ui32Base);
131extern bool QEIErrorGet(uint32_t ui32Base);
132extern void QEIFilterEnable(uint32_t ui32Base);
133extern void QEIFilterDisable(uint32_t ui32Base);
134extern void QEIFilterConfigure(uint32_t ui32Base, uint32_t ui32FiltCnt);
135extern void QEIVelocityEnable(uint32_t ui32Base);
136extern void QEIVelocityDisable(uint32_t ui32Base);
137extern void QEIVelocityConfigure(uint32_t ui32Base, uint32_t ui32PreDiv,
138                                 uint32_t ui32Period);
139extern uint32_t QEIVelocityGet(uint32_t ui32Base);
140extern void QEIIntRegister(uint32_t ui32Base, void (*pfnHandler)(void));
141extern void QEIIntUnregister(uint32_t ui32Base);
142extern void QEIIntEnable(uint32_t ui32Base, uint32_t ui32IntFlags);
143extern void QEIIntDisable(uint32_t ui32Base, uint32_t ui32IntFlags);
144extern uint32_t QEIIntStatus(uint32_t ui32Base, bool bMasked);
145extern void QEIIntClear(uint32_t ui32Base, uint32_t ui32IntFlags);
146
147//*****************************************************************************
148//
149// Mark the end of the C bindings section for C++ compilers.
150//
151//*****************************************************************************
152#ifdef __cplusplus
153}
154#endif
155
156#endif // __DRIVERLIB_QEI_H__