diff options
author | Stephane D'Alu <sdalu@sdalu.com> | 2016-06-29 12:14:15 +0200 |
---|---|---|
committer | Stephane D'Alu <sdalu@sdalu.com> | 2016-06-29 12:14:15 +0200 |
commit | dde47ff1ab6d8155adfbaca1b912577f051509b4 (patch) | |
tree | dd65b040c52131f6220600c4552a73c1aaa67e91 /os | |
parent | 7b8e263f8cd26a8c0413eed3560d44a615f812d5 (diff) | |
download | ChibiOS-Contrib-dde47ff1ab6d8155adfbaca1b912577f051509b4.tar.gz ChibiOS-Contrib-dde47ff1ab6d8155adfbaca1b912577f051509b4.tar.bz2 ChibiOS-Contrib-dde47ff1ab6d8155adfbaca1b912577f051509b4.zip |
renamed QDEC1 to QDEC0, misc...
Diffstat (limited to 'os')
-rw-r--r-- | os/hal/ports/NRF51/NRF51822/hal_qei_lld.c | 22 | ||||
-rw-r--r-- | os/hal/ports/NRF51/NRF51822/hal_qei_lld.h | 38 |
2 files changed, 42 insertions, 18 deletions
diff --git a/os/hal/ports/NRF51/NRF51822/hal_qei_lld.c b/os/hal/ports/NRF51/NRF51822/hal_qei_lld.c index 7d78f1d..f74f5f7 100644 --- a/os/hal/ports/NRF51/NRF51822/hal_qei_lld.c +++ b/os/hal/ports/NRF51/NRF51822/hal_qei_lld.c @@ -39,13 +39,18 @@ static void serve_interrupt(QEIDriver *qeip) {
NRF_QDEC_Type *qdec = qeip->qdec;
+ /* Accumulator overflowed
+ */
if (qdec->EVENTS_ACCOF) {
qdec->EVENTS_ACCOF = 0;
+
qeip->overflowed++;
if (qeip->config->overflowed_cb)
qeip->config->overflowed_cb(qeip);
}
-
+
+ /* Report ready
+ */
if (qdec->EVENTS_REPORTRDY) {
qdec->EVENTS_REPORTRDY = 0;
@@ -130,7 +135,7 @@ static void serve_interrupt(QEIDriver *qeip) { /**
* @brief QEID1 driver identifier.
*/
-#if NRF51_QEI_USE_QDEC1 || defined(__DOXYGEN__)
+#if NRF51_QEI_USE_QDEC0 || defined(__DOXYGEN__)
QEIDriver QEID1;
#endif
@@ -147,7 +152,7 @@ QEIDriver QEID1; /* Driver interrupt handlers. */
/*===========================================================================*/
-#if NRF51_QEI_USE_QDEC1 == TRUE
+#if NRF51_QEI_USE_QDEC0 == TRUE
/**
* @brief Quadrature decoder vector (QDEC)
*
@@ -172,7 +177,7 @@ OSAL_IRQ_HANDLER(Vector88) { */
void qei_lld_init(void) {
-#if NRF51_QEI_USE_QDEC1
+#if NRF51_QEI_USE_QDEC0 == TRUE
/* Driver initialization.*/
qeiObjectInit(&QEID1);
QEID1.qdec = NRF_QDEC;
@@ -201,9 +206,9 @@ void qei_lld_start(QEIDriver *qeip) { // Set interrupt masks and enable interrupt
qdec->INTENSET = QDEC_INTENSET_REPORTRDY_Msk |
QDEC_INTENSET_ACCOF_Msk;
-#if NRF51_QEI_USE_QDEC1
+#if NRF51_QEI_USE_QDEC0 == TRUE
if (&QEID1 == qeip) {
- nvicEnableVector(QDEC_IRQn, NRF51_QEI_IRQ_PRIORITY);
+ nvicEnableVector(QDEC_IRQn, NRF51_QEI_QDEC0_IRQ_PRIORITY);
}
#endif
@@ -212,8 +217,7 @@ void qei_lld_start(QEIDriver *qeip) { qdec->PSELB = PAL_PAD(cfg->phase_b);
// Select (optional) pin for LED, and configure it
- qdec->PSELLED = (cfg->led == PAL_NOLINE) ? (uint32_t)-1
- : PAL_PAD(cfg->led);
+ qdec->PSELLED = PAL_PAD(cfg->led);
qdec->LEDPOL = ((cfg->led_polarity == QEI_LED_POLARITY_LOW)
? QDEC_LEDPOL_LEDPOL_ActiveLow
: QDEC_LEDPOL_LEDPOL_ActiveHigh)
@@ -257,7 +261,7 @@ void qei_lld_stop(QEIDriver *qeip) { if (qeip->state == QEI_READY) {
qdec->TASKS_STOP = 1;
qdec->ENABLE = 0;
-#if NRF51_QEI_USE_QDEC1
+#if NRF51_QEI_USE_QDEC0 == TRUE
if (&QEID1 == qeip) {
nvicDisableVector(QDEC_IRQn);
}
diff --git a/os/hal/ports/NRF51/NRF51822/hal_qei_lld.h b/os/hal/ports/NRF51/NRF51822/hal_qei_lld.h index e4e89b6..f8f29b9 100644 --- a/os/hal/ports/NRF51/NRF51822/hal_qei_lld.h +++ b/os/hal/ports/NRF51/NRF51822/hal_qei_lld.h @@ -56,15 +56,15 @@ * @details If set to @p TRUE the support for QEID1 is included.
* @note The default is @p FALSE.
*/
-#if !defined(NRF51_QEI_USE_QDEC1) || defined(__DOXYGEN__)
-#define NRF51_QEI_USE_QDEC1 FALSE
+#if !defined(NRF51_QEI_USE_QDEC0) || defined(__DOXYGEN__)
+#define NRF51_QEI_USE_QDEC0 FALSE
#endif
/**
* @brief QEID interrupt priority level setting.
*/
-#if !defined(NRF51_QEI_IRQ_PRIORITY) || defined(__DOXYGEN__)
-#define NRF51_QEI_IRQ_PRIORITY 2
+#if !defined(NRF51_QEI_QDEC0_IRQ_PRIORITY) || defined(__DOXYGEN__)
+#define NRF51_QEI_QDEC0_IRQ_PRIORITY 2
#endif
/** @} */
@@ -72,11 +72,16 @@ /* Derived constants and error checks. */
/*===========================================================================*/
-#if NRF51_QEI_USE_QDEC1 && \
- !OSAL_IRQ_IS_VALID_PRIORITY(NRF51_QEI_IRQ_PRIORITY)
-#error "Invalid IRQ priority assigned to QDEC1"
+#if NRF51_QEI_USE_QDEC0 && \
+ !OSAL_IRQ_IS_VALID_PRIORITY(NRF51_QEI_QDEC0_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to QDEC0"
#endif
+#if NRF51_QEI_USE_QDEC0 == FALSE
+#error "Requesting QEI driver, but no QDEC peripheric attached"
+#endif
+
+
/*===========================================================================*/
/* Driver data structures and types. */
/*===========================================================================*/
@@ -277,6 +282,7 @@ struct QEIDriver { #endif
/* End of the mandatory fields.*/
/**
+ * @brief Counter
*/
qeicnt_t count;
/**
@@ -285,7 +291,7 @@ struct QEIDriver { */
uint32_t overflowed;
/**
- * @brief Pointer to the ADCx registers block.
+ * @brief Pointer to the QDECx registers block.
*/
NRF_QDEC_Type *qdec;
};
@@ -305,11 +311,25 @@ struct QEIDriver { #define qei_lld_get_count(qeip) ((qeip)->count)
+/**
+ * @brief Set the counter value.
+ *
+ * @param[in] qeip pointer to the @p QEIDriver object
+ * @param[in] value counter value
+ *
+ * @notapi
+ */
+#define qei_lld_set_count(qeip, value) \
+ do { \
+ (qeip)->count = value; \
+ } while(0)
+
+
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
-#if NRF51_QEI_USE_QDEC1 && !defined(__DOXYGEN__)
+#if NRF51_QEI_USE_QDEC0 && !defined(__DOXYGEN__)
extern QEIDriver QEID1;
#endif
|