From 5fee893778fad0d2b1a17e812aa0331f81a3ba7a Mon Sep 17 00:00:00 2001 From: Stephane D'Alu Date: Wed, 29 Jun 2016 12:26:22 +0200 Subject: conditionally include support for LED --- os/hal/ports/NRF51/NRF51822/hal_qei_lld.c | 10 +++++++++- os/hal/ports/NRF51/NRF51822/hal_qei_lld.h | 14 +++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'os') 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 @@ -51,6 +51,16 @@ * @name Configuration options * @{ */ +/** + * @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. @@ -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 * -- cgit v1.2.3