void QDEC_IRQHandler(void) { nrf_drv_qdec_event_t event; if ( nrf_qdec_event_check(NRF_QDEC_EVENT_SAMPLERDY) && nrf_qdec_int_enable_check(NRF_QDEC_INT_SAMPLERDY_MASK) ) { nrf_qdec_event_clear(NRF_QDEC_EVENT_SAMPLERDY); event.type = NRF_QDEC_EVENT_SAMPLERDY; event.data.sample.value = (int8_t)nrf_qdec_sample_get(); m_qdec_event_handler(event); } if ( nrf_qdec_event_check(NRF_QDEC_EVENT_REPORTRDY) && nrf_qdec_int_enable_check(NRF_QDEC_INT_REPORTRDY_MASK) ) { nrf_qdec_event_clear(NRF_QDEC_EVENT_REPORTRDY); event.type = NRF_QDEC_EVENT_REPORTRDY; event.data.report.acc = (int16_t)nrf_qdec_accread_get(); event.data.report.accdbl = (uint16_t)nrf_qdec_accdblread_get(); m_qdec_event_handler(event); } if ( nrf_qdec_event_check(NRF_QDEC_EVENT_ACCOF) && nrf_qdec_int_enable_check(NRF_QDEC_INT_ACCOF_MASK) ) { nrf_qdec_event_clear(NRF_QDEC_EVENT_ACCOF); event.type = NRF_QDEC_EVENT_ACCOF; m_qdec_event_handler(event); } }
void nrf_drv_qdec_accumulators_read(int16_t * p_acc, int16_t * p_accdbl) { ASSERT(m_state == NRF_DRV_STATE_POWERED_ON); nrf_qdec_task_trigger(NRF_QDEC_TASK_READCLRACC); *p_acc = (int16_t)nrf_qdec_accread_get(); *p_accdbl = (int16_t)nrf_qdec_accdblread_get(); }
void nrfx_qdec_accumulators_read(int16_t * p_acc, int16_t * p_accdbl) { NRFX_ASSERT(m_state == NRFX_DRV_STATE_POWERED_ON); nrf_qdec_task_trigger(NRF_QDEC_TASK_READCLRACC); *p_acc = (int16_t)nrf_qdec_accread_get(); *p_accdbl = (int16_t)nrf_qdec_accdblread_get(); NRFX_LOG_DEBUG("Accumulators data, ACC register:"); NRFX_LOG_HEXDUMP_DEBUG((uint8_t *)p_acc, sizeof(p_acc[0])); NRFX_LOG_DEBUG("Accumulators data, ACCDBL register:"); NRFX_LOG_HEXDUMP_DEBUG((uint8_t *)p_accdbl, sizeof(p_accdbl[0])); }
void nrfx_qdec_irq_handler(void) { nrfx_qdec_event_t event; if ( nrf_qdec_event_check(NRF_QDEC_EVENT_SAMPLERDY) && nrf_qdec_int_enable_check(NRF_QDEC_INT_SAMPLERDY_MASK) ) { nrf_qdec_event_clear(NRF_QDEC_EVENT_SAMPLERDY); NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(NRF_QDEC_EVENT_SAMPLERDY)); event.type = NRF_QDEC_EVENT_SAMPLERDY; event.data.sample.value = (int8_t)nrf_qdec_sample_get(); m_qdec_event_handler(event); } if ( nrf_qdec_event_check(NRF_QDEC_EVENT_REPORTRDY) && nrf_qdec_int_enable_check(NRF_QDEC_INT_REPORTRDY_MASK) ) { nrf_qdec_event_clear(NRF_QDEC_EVENT_REPORTRDY); NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(NRF_QDEC_EVENT_REPORTRDY)); event.type = NRF_QDEC_EVENT_REPORTRDY; event.data.report.acc = (int16_t)nrf_qdec_accread_get(); event.data.report.accdbl = (uint16_t)nrf_qdec_accdblread_get(); m_qdec_event_handler(event); } if ( nrf_qdec_event_check(NRF_QDEC_EVENT_ACCOF) && nrf_qdec_int_enable_check(NRF_QDEC_INT_ACCOF_MASK) ) { nrf_qdec_event_clear(NRF_QDEC_EVENT_ACCOF); NRFX_LOG_DEBUG("Event: %s.", EVT_TO_STR(NRF_QDEC_EVENT_ACCOF)); event.type = NRF_QDEC_EVENT_ACCOF; m_qdec_event_handler(event); } }