conditionnaly compile accumulator overflow notification
This commit is contained in:
parent
a8b2364267
commit
e1e600b5ad
|
@ -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,6 +165,7 @@ static void serve_interrupt(QEIDriver *qeip) {
|
|||
if (qeip->config->overflowed_cb)
|
||||
qeip->config->overflowed_cb(qeip);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Report ready
|
||||
*/
|
||||
|
@ -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,8 +314,13 @@ 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);
|
||||
|
@ -329,7 +341,9 @@ 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;
|
||||
|
|
|
@ -60,6 +60,16 @@
|
|||
#define NRF51_QEI_USE_LED FALSE
|
||||
#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.
|
||||
|
@ -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.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue