diff options
Diffstat (limited to 'os/hal/include/hal_qei.h')
-rw-r--r-- | os/hal/include/hal_qei.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/os/hal/include/hal_qei.h b/os/hal/include/hal_qei.h index 92f03fc..1032c84 100644 --- a/os/hal/include/hal_qei.h +++ b/os/hal/include/hal_qei.h @@ -65,8 +65,36 @@ typedef struct QEIDriver QEIDriver; */
typedef void (*qeicallback_t)(QEIDriver *qeip);
+/**
+ * @brief Driver possible handling of counter overflow/underflow.
+ *
+ * @details When counter is going to overflow, the new value is
+ * computed according to this mode in such a way that
+ * the counter will either wrap around, stay unchange
+ * or reach min/max
+ *
+ * @note All driver implementation should support the
+ * QEI_OVERFLOW_WRAP mode.
+ *
+ * @note Mode QEI_OVERFLOW_DISCARD and QEI_OVERFLOW_MINMAX are included
+ * if QEI_USE_OVERFLOW_DISCARD and QEI_USE_OVERFLOW_MINMAX are
+ * set to TRUE in halconf_community.h and are not necessary supported
+ * by all drivers
+ */
+typedef enum {
+ QEI_OVERFLOW_WRAP = 0, /**< Counter value will wrap around. */
+#if QEI_USE_OVERFLOW_DISCARD == TRUE
+ QEI_OVERFLOW_DISCARD = 1, /**< Counter doesn't change. */
+#endif
+#if QEI_USE_OVERFLOW_MINMAX == TRUE
+ QEI_OVERFLOW_MINMAX = 2, /**< Counter will be updated upto min or max.*/
+#endif
+} qeioverflow_t;
+
+
#include "hal_qei_lld.h"
+
/*===========================================================================*/
/* Driver macros. */
/*===========================================================================*/
@@ -119,6 +147,8 @@ extern "C" { qeicnt_t qeiGetCount(QEIDriver *qeip);
qeidelta_t qeiUpdate(QEIDriver *qeip);
qeidelta_t qeiUpdateI(QEIDriver *qeip);
+ bool qei_adjust_count(qeicnt_t *count, qeidelta_t *delta,
+ qeicnt_t min, qeicnt_t max, qeioverflow_t mode);
#ifdef __cplusplus
}
#endif
|