aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/include
diff options
context:
space:
mode:
authorUladzimir Pylinski <barthess@yandex.ru>2016-07-07 21:58:53 +0300
committerGitHub <noreply@github.com>2016-07-07 21:58:53 +0300
commitc7f7b70596d200afb76c3c8a24d4ddaaa61a2f1e (patch)
treec3acb08835925efc056c106cffb586dd0434395b /os/hal/include
parent0131027151415075106a82984b441ebe26d90047 (diff)
parent9c88423d66e9b4eafecc658058f25f79e08ff120 (diff)
downloadChibiOS-Contrib-c7f7b70596d200afb76c3c8a24d4ddaaa61a2f1e.tar.gz
ChibiOS-Contrib-c7f7b70596d200afb76c3c8a24d4ddaaa61a2f1e.tar.bz2
ChibiOS-Contrib-c7f7b70596d200afb76c3c8a24d4ddaaa61a2f1e.zip
Merge pull request #85 from sdalu/qei
Merged QEI driver for NRF51
Diffstat (limited to 'os/hal/include')
-rw-r--r--os/hal/include/hal_qei.h30
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