aboutsummaryrefslogtreecommitdiffstats
path: root/os
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
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')
-rw-r--r--os/hal/ports/NRF51/NRF51822/hal_qei_lld.c10
-rw-r--r--os/hal/ports/NRF51/NRF51822/hal_qei_lld.h14
2 files changed, 22 insertions, 2 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
}
}
diff --git a/os/hal/ports/NRF51/NRF51822/hal_qei_lld.h b/os/hal/ports/NRF51/NRF51822/hal_qei_lld.h
index f8f29b9..e1485e3 100644
--- a/os/hal/ports/NRF51/NRF51822/hal_qei_lld.h
+++ b/os/hal/ports/NRF51/NRF51822/hal_qei_lld.h
@@ -52,6 +52,16 @@
* @{
*/
/**
+ * @brief LED control enable switch.
+ * @details If set to @p TRUE the support for LED control
+ * is included.
+ * @note The default is @p FALSE.
+ */
+#if !defined(NRF51_QEI_USE_LED) || defined(__DOXYGEN__)
+#define NRF51_QEI_USE_LED 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.
@@ -217,8 +227,9 @@ typedef struct {
* @brief Line for reading Phase B
*/
ioline_t phase_b;
+#if (NRF51_QEI_USE_LED == TRUE) || defined(__DOXYGEN__)
/**
- * @brief Line to use to control LED
+ * @brief Line used to control LED
*
* @note If LED is not controlled by MCU, you need to use the
* PAL_NOLINE value.
@@ -239,6 +250,7 @@ typedef struct {
* @brief LED polarity to used (when LED is controlled by MCU)
*/
uint8_t led_polarity;
+#endif
/**
* @brief Activate debouncing filter
*