amiro-os / hal / include / qei.h @ f12b953d
History | View | Annotate | Download (3.869 KB)
1 | 3f899f5d | Thomas Schöpping | /**
|
---|---|---|---|
2 | * @file qei.h
|
||
3 | * @brief QEI Driver macros and structures.
|
||
4 | *
|
||
5 | * @addtogroup QEI
|
||
6 | * @{
|
||
7 | */
|
||
8 | |||
9 | 58fe0e0b | Thomas Schöpping | #ifndef _QEI_H_
|
10 | #define _QEI_H_
|
||
11 | |||
12 | #if HAL_USE_QEI || defined(__DOXYGEN__)
|
||
13 | |||
14 | /*===========================================================================*/
|
||
15 | /* Driver constants. */
|
||
16 | /*===========================================================================*/
|
||
17 | |||
18 | /*===========================================================================*/
|
||
19 | /* Driver pre-compile time settings. */
|
||
20 | /*===========================================================================*/
|
||
21 | |||
22 | /*===========================================================================*/
|
||
23 | /* Derived constants and error checks. */
|
||
24 | /*===========================================================================*/
|
||
25 | |||
26 | /*===========================================================================*/
|
||
27 | /* Driver data structures and types. */
|
||
28 | /*===========================================================================*/
|
||
29 | |||
30 | /**
|
||
31 | * @brief Driver state machine possible states.
|
||
32 | */
|
||
33 | typedef enum { |
||
34 | QEI_UNINIT = 0, /**< Not initialized. */ |
||
35 | QEI_STOP = 1, /**< Stopped. */ |
||
36 | QEI_READY = 2, /**< Ready. */ |
||
37 | QEI_ACTIVE = 4, /**< Active. */ |
||
38 | } qeistate_t; |
||
39 | |||
40 | /**
|
||
41 | * @brief Type of a structure representing an QEI driver.
|
||
42 | */
|
||
43 | typedef struct QEIDriver QEIDriver; |
||
44 | |||
45 | #include "qei_lld.h" |
||
46 | |||
47 | /*===========================================================================*/
|
||
48 | /* Driver macros. */
|
||
49 | /*===========================================================================*/
|
||
50 | |||
51 | /**
|
||
52 | * @name Macro Functions
|
||
53 | * @{
|
||
54 | */
|
||
55 | /**
|
||
56 | * @brief Enables the quadrature encoder.
|
||
57 | *
|
||
58 | * @param[in] qeip pointer to the @p QEIDriver object
|
||
59 | *
|
||
60 | * @iclass
|
||
61 | */
|
||
62 | #define qeiEnableI(qeip) qei_lld_enable(qeip)
|
||
63 | |||
64 | /**
|
||
65 | * @brief Disables the quadrature encoder.
|
||
66 | *
|
||
67 | * @param[in] qeip pointer to the @p QEIDriver object
|
||
68 | *
|
||
69 | * @iclass
|
||
70 | */
|
||
71 | #define qeiDisableI(qeip) qei_lld_disable(qeip)
|
||
72 | |||
73 | /**
|
||
74 | * @brief Returns the direction of the last transition.
|
||
75 | * @details The direction is defined as boolean and is
|
||
76 | * calculated at each transition on any input.
|
||
77 | *
|
||
78 | * @param[in] qeip pointer to the @p QEIDriver object
|
||
79 | * @return The request direction.
|
||
80 | * @retval FALSE Position counted up.
|
||
81 | * @retval TRUE Position counted down.
|
||
82 | * @iclass
|
||
83 | */
|
||
84 | #define qeiGetDirectionI(qeip) qei_lld_get_direction(qeip)
|
||
85 | |||
86 | /**
|
||
87 | * @brief Returns the position of the encoder.
|
||
88 | * @details The position is defined as number of pulses since last reset.
|
||
89 | *
|
||
90 | * @param[in] qeip pointer to the @p QEIDriver object
|
||
91 | * @return The number of pulses.
|
||
92 | *
|
||
93 | * @iclass
|
||
94 | */
|
||
95 | #define qeiGetPositionI(qeip) qei_lld_get_position(qeip)
|
||
96 | |||
97 | /**
|
||
98 | * @brief Returns the range of the encoder.
|
||
99 | * @details The range is defined as number of maximum pulse count.
|
||
100 | *
|
||
101 | * @param[in] qeip pointer to the @p QEIDriver object
|
||
102 | * @return The number of pulses.
|
||
103 | *
|
||
104 | * @iclass
|
||
105 | */
|
||
106 | #define qeiGetRangeI(qeip) qei_lld_get_range(qeip)
|
||
107 | /** @} */
|
||
108 | |||
109 | /*===========================================================================*/
|
||
110 | /* External declarations. */
|
||
111 | /*===========================================================================*/
|
||
112 | |||
113 | #ifdef __cplusplus
|
||
114 | extern "C" { |
||
115 | #endif
|
||
116 | void qeiInit(void); |
||
117 | void qeiObjectInit(QEIDriver *qeip);
|
||
118 | void qeiStart(QEIDriver *qeip, const QEIConfig *config); |
||
119 | void qeiStop(QEIDriver *qeip);
|
||
120 | void qeiEnable(QEIDriver *qeip);
|
||
121 | void qeiDisable(QEIDriver *qeip);
|
||
122 | #ifdef __cplusplus
|
||
123 | } |
||
124 | #endif
|
||
125 | |||
126 | #endif /* HAL_USE_QEI */ |
||
127 | |||
128 | #endif /* _QEI_H_ */ |
||
129 | 3f899f5d | Thomas Schöpping | |
130 | /** @} */ |