aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports
diff options
context:
space:
mode:
authorStephane D'Alu <sdalu@sdalu.com>2016-06-29 21:27:56 +0200
committerStephane D'Alu <sdalu@sdalu.com>2016-06-29 21:27:56 +0200
commite1e600b5ada75fe1bd77e13cb799433898cb848a (patch)
tree61a42efed3bd96c716d87e00e66d9fbc4ab961fc /os/hal/ports
parenta8b2364267be59dd2bc9d02bc6923a629bcecd72 (diff)
downloadChibiOS-Contrib-e1e600b5ada75fe1bd77e13cb799433898cb848a.tar.gz
ChibiOS-Contrib-e1e600b5ada75fe1bd77e13cb799433898cb848a.tar.bz2
ChibiOS-Contrib-e1e600b5ada75fe1bd77e13cb799433898cb848a.zip
conditionnaly compile accumulator overflow notification
Diffstat (limited to 'os/hal/ports')
-rw-r--r--os/hal/ports/NRF51/NRF51822/hal_qei_lld.c22
-rw-r--r--os/hal/ports/NRF51/NRF51822/hal_qei_lld.h14
2 files changed, 32 insertions, 4 deletions
diff --git a/os/hal/ports/NRF51/NRF51822/hal_qei_lld.c b/os/hal/ports/NRF51/NRF51822/hal_qei_lld.c
index 9b1b6bb..595df89 100644
--- a/os/hal/ports/NRF51/NRF51822/hal_qei_lld.c
+++ b/os/hal/ports/NRF51/NRF51822/hal_qei_lld.c
@@ -155,6 +155,7 @@ QEIDriver QEID1;
static void serve_interrupt(QEIDriver *qeip) {
NRF_QDEC_Type *qdec = qeip->qdec;
+#if NRF51_QEI_USE_ACC_OVERFLOW_CB == TRUE
/* Accumulator overflowed
*/
if (qdec->EVENTS_ACCOF) {
@@ -164,7 +165,8 @@ static void serve_interrupt(QEIDriver *qeip) {
if (qeip->config->overflowed_cb)
qeip->config->overflowed_cb(qeip);
}
-
+#endif
+
/* Report ready
*/
if (qdec->EVENTS_REPORTRDY) {
@@ -241,8 +243,13 @@ void qei_lld_start(QEIDriver *qeip) {
#endif
// Set interrupt masks and enable interrupt
+#if NRF51_QEI_USE_ACC_OVERFLOW_CB == TRUE
qdec->INTENSET = QDEC_INTENSET_REPORTRDY_Msk |
QDEC_INTENSET_ACCOF_Msk;
+#else
+ qdec->INTENSET = QDEC_INTENSET_REPORTRDY_Msk;
+#endif
+
#if NRF51_QEI_USE_QDEC0 == TRUE
if (&QEID1 == qeip) {
nvicEnableVector(QDEC_IRQn, NRF51_QEI_QDEC0_IRQ_PRIORITY);
@@ -307,9 +314,14 @@ void qei_lld_stop(QEIDriver *qeip) {
nvicDisableVector(QDEC_IRQn);
}
#endif
- qdec->INTENCLR = QDEC_INTENSET_REPORTRDY_Msk |
- QDEC_INTENSET_ACCOF_Msk;
+#if NRF51_QEI_USE_ACC_OVERFLOW_CB == TRUE
+ qdec->INTENCLR = QDEC_INTENCLR_REPORTRDY_Msk |
+ QDEC_INTENCLR_ACCOF_Msk;
+#else
+ qdec->INTENCLR = QDEC_INTENCLR_REPORTRDY_Msk;
+#endif
+
// Return pins to reset state
palSetLineMode(cfg->phase_a, PAL_MODE_RESET);
palSetLineMode(cfg->phase_b, PAL_MODE_RESET);
@@ -329,8 +341,10 @@ void qei_lld_stop(QEIDriver *qeip) {
* @notapi
*/
void qei_lld_enable(QEIDriver *qeip) {
+#if NRF51_QEI_USE_ACC_OVERFLOW_CB == TRUE
qeip->overflowed = 0;
-
+#endif
+
qeip->qdec->EVENTS_SAMPLERDY = 0;
qeip->qdec->EVENTS_REPORTRDY = 0;
qeip->qdec->EVENTS_ACCOF = 0;
diff --git a/os/hal/ports/NRF51/NRF51822/hal_qei_lld.h b/os/hal/ports/NRF51/NRF51822/hal_qei_lld.h
index ed5d9ae..aa3d1e8 100644
--- a/os/hal/ports/NRF51/NRF51822/hal_qei_lld.h
+++ b/os/hal/ports/NRF51/NRF51822/hal_qei_lld.h
@@ -61,6 +61,16 @@
#endif
/**
+ * @brief Accumulator overflow notification enable switch.
+ * @details If set to @p TRUE the support for accumulator overflow
+ * is included.
+ * @note The default is @p FALSE.
+ */
+#if !defined(NRF51_QEI_USE_ACC_OVERFLOW_CB) || defined(__DOXYGEN__)
+#define NRF51_QEI_USE_ACC_OVERFLOW_CB FALSE
+#endif
+
+/**
* @brief QEID1 driver enable switch.
* @details If set to @p TRUE the support for QEID1 is included.
* @note The default is @p FALSE.
@@ -263,6 +273,7 @@ typedef struct {
* @details Default to QEI_REPORT_10
*/
qeireport_t report;
+#if NRF51_QEI_USE_ACC_OVERFLOW_CB == TRUE
/**
* @brief Notify of internal accumulator overflowed
*
@@ -270,6 +281,7 @@ typedef struct {
* @note Called from ISR context.
*/
qeicallback_t overflowed_cb;
+#endif
} QEIConfig;
/**
@@ -296,11 +308,13 @@ struct QEIDriver {
* @brief Counter
*/
qeicnt_t count;
+#if NRF51_QEI_USE_ACC_OVERFLOW_CB == TRUE
/**
* @brief Number of time the MCU discarded updates due to
* accumulator overflow
*/
uint32_t overflowed;
+#endif
/**
* @brief Pointer to the QDECx registers block.
*/