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