aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports/NRF51/NRF51822/hal_qei_lld.c
diff options
context:
space:
mode:
authorStephane D'Alu <sdalu@sdalu.com>2016-06-29 12:26:22 +0200
committerStephane D'Alu <sdalu@sdalu.com>2016-06-29 12:26:22 +0200
commit5fee893778fad0d2b1a17e812aa0331f81a3ba7a (patch)
treef1ca8998daa3ed6674c21795b7bfaf2da9db0f96 /os/hal/ports/NRF51/NRF51822/hal_qei_lld.c
parentdde47ff1ab6d8155adfbaca1b912577f051509b4 (diff)
downloadChibiOS-Contrib-5fee893778fad0d2b1a17e812aa0331f81a3ba7a.tar.gz
ChibiOS-Contrib-5fee893778fad0d2b1a17e812aa0331f81a3ba7a.tar.bz2
ChibiOS-Contrib-5fee893778fad0d2b1a17e812aa0331f81a3ba7a.zip
conditionally include support for LED
Diffstat (limited to 'os/hal/ports/NRF51/NRF51822/hal_qei_lld.c')
-rw-r--r--os/hal/ports/NRF51/NRF51822/hal_qei_lld.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/os/hal/ports/NRF51/NRF51822/hal_qei_lld.c b/os/hal/ports/NRF51/NRF51822/hal_qei_lld.c
index f74f5f7..ffbed95 100644
--- a/os/hal/ports/NRF51/NRF51822/hal_qei_lld.c
+++ b/os/hal/ports/NRF51/NRF51822/hal_qei_lld.c
@@ -199,9 +199,11 @@ void qei_lld_start(QEIDriver *qeip) {
// Set Pins
palSetLineMode(cfg->phase_a, PAL_MODE_INPUT);
palSetLineMode(cfg->phase_b, PAL_MODE_INPUT);
+#if NRF51_QEI_USE_LED == TRUE
if (cfg->led != PAL_NOLINE) {
palSetLineMode(cfg->led, PAL_MODE_INPUT);
}
+#endif
// Set interrupt masks and enable interrupt
qdec->INTENSET = QDEC_INTENSET_REPORTRDY_Msk |
@@ -217,13 +219,17 @@ void qei_lld_start(QEIDriver *qeip) {
qdec->PSELB = PAL_PAD(cfg->phase_b);
// Select (optional) pin for LED, and configure it
+#if NRF51_QEI_USE_LED == TRUE
qdec->PSELLED = PAL_PAD(cfg->led);
qdec->LEDPOL = ((cfg->led_polarity == QEI_LED_POLARITY_LOW)
? QDEC_LEDPOL_LEDPOL_ActiveLow
: QDEC_LEDPOL_LEDPOL_ActiveHigh)
<< QDEC_LEDPOL_LEDPOL_Pos;
qdec->LEDPRE = cfg->led_warming;
-
+#else
+ qdec->PSELLED = (uint32_t)-1;
+#endif
+
// Set sampling resolution and debouncing
qdec->SAMPLEPER = cfg->resolution;
qdec->DBFEN = (cfg->debouncing ? QDEC_DBFEN_DBFEN_Enabled
@@ -272,9 +278,11 @@ void qei_lld_stop(QEIDriver *qeip) {
// Return pins to reset state
palSetLineMode(cfg->phase_a, PAL_MODE_RESET);
palSetLineMode(cfg->phase_b, PAL_MODE_RESET);
+#if NRF51_QEI_USE_LED == TRUE
if (cfg->led != PAL_NOLINE) {
palSetLineMode(cfg->led, PAL_MODE_RESET);
}
+#endif
}
}