Statistics
| Branch: | Tag: | Revision:

amiro-os / os / hal / include / hal_qei.h @ e05848a6

History | View | Annotate | Download (4.631 KB)

1 e545e620 Thomas Schöpping
/*
2
AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
3
Copyright (C) 2016..2018  Thomas Schöpping et al.
4

5
This program is free software: you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation, either version 3 of the License, or
8
(at your option) any later version.
9

10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
GNU General Public License for more details.
14

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