static void irq_handler(NRF_PWM_Type * p_pwm, pwm_control_block_t * p_cb) { // The user handler is called for SEQEND0 and SEQEND1 events only when the // user asks for it (by setting proper flags when starting the playback). if (nrf_pwm_event_check(p_pwm, NRF_PWM_EVENT_SEQEND0)) { nrf_pwm_event_clear(p_pwm, NRF_PWM_EVENT_SEQEND0); if ((p_cb->flags & NRFX_PWM_FLAG_SIGNAL_END_SEQ0) && p_cb->handler) { p_cb->handler(NRFX_PWM_EVT_END_SEQ0); } } if (nrf_pwm_event_check(p_pwm, NRF_PWM_EVENT_SEQEND1)) { nrf_pwm_event_clear(p_pwm, NRF_PWM_EVENT_SEQEND1); if ((p_cb->flags & NRFX_PWM_FLAG_SIGNAL_END_SEQ1) && p_cb->handler) { p_cb->handler(NRFX_PWM_EVT_END_SEQ1); } } // For LOOPSDONE the handler is called by default, but the user can disable // this (via flags). if (nrf_pwm_event_check(p_pwm, NRF_PWM_EVENT_LOOPSDONE)) { nrf_pwm_event_clear(p_pwm, NRF_PWM_EVENT_LOOPSDONE); if (!(p_cb->flags & NRFX_PWM_FLAG_NO_EVT_FINISHED) && p_cb->handler) { p_cb->handler(NRFX_PWM_EVT_FINISHED); } } // The STOPPED event is always propagated to the user handler. if (nrf_pwm_event_check(p_pwm, NRF_PWM_EVENT_STOPPED)) { nrf_pwm_event_clear(p_pwm, NRF_PWM_EVENT_STOPPED); p_cb->state = NRFX_DRV_STATE_INITIALIZED; if (p_cb->handler) { p_cb->handler(NRFX_PWM_EVT_STOPPED); } } }
static void irq_handler(NRF_PWM_Type * p_pwm, pwm_control_block_t * p_cb) { ASSERT(p_cb->handler); // The SEQEND0 and SEQEND1 events are only handled when the user asked for // it (by setting proper flags when starting the playback). if (nrf_pwm_int_enable_check(p_pwm, NRF_PWM_INT_SEQEND0_MASK) && nrf_pwm_event_check(p_pwm, NRF_PWM_EVENT_SEQEND0)) { nrf_pwm_event_clear(p_pwm, NRF_PWM_EVENT_SEQEND0); p_cb->handler(NRF_DRV_PWM_EVT_END_SEQ0); } if (nrf_pwm_int_enable_check(p_pwm, NRF_PWM_INT_SEQEND1_MASK) && nrf_pwm_event_check(p_pwm, NRF_PWM_EVENT_SEQEND1)) { nrf_pwm_event_clear(p_pwm, NRF_PWM_EVENT_SEQEND1); p_cb->handler(NRF_DRV_PWM_EVT_END_SEQ1); } // The LOOPSDONE event is handled by default, but this can be disabled. if (nrf_pwm_int_enable_check(p_pwm, NRF_PWM_INT_LOOPSDONE_MASK) && nrf_pwm_event_check(p_pwm, NRF_PWM_EVENT_LOOPSDONE)) { nrf_pwm_event_clear(p_pwm, NRF_PWM_EVENT_LOOPSDONE); p_cb->handler(NRF_DRV_PWM_EVT_FINISHED); } if (nrf_pwm_event_check(p_pwm, NRF_PWM_EVENT_STOPPED)) { nrf_pwm_event_clear(p_pwm, NRF_PWM_EVENT_STOPPED); p_cb->state = NRF_DRV_STATE_INITIALIZED; p_cb->handler(NRF_DRV_PWM_EVT_STOPPED); } }
bool nrf_drv_pwm_is_stopped(nrf_drv_pwm_t const * const p_instance) { pwm_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx]; ASSERT(p_cb->state != NRF_DRV_STATE_UNINITIALIZED); // If the event handler is used (interrupts are enabled), the state will // be changed in interrupt handler when the STOPPED event occurs. if (p_cb->state != NRF_DRV_STATE_POWERED_ON) { return true; } // If interrupts are disabled, we must check the STOPPED event here. if (nrf_pwm_event_check(p_instance->p_registers, NRF_PWM_EVENT_STOPPED)) { p_cb->state = NRF_DRV_STATE_INITIALIZED; return true; } return false; }
bool nrfx_pwm_is_stopped(nrfx_pwm_t const * const p_instance) { pwm_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx]; NRFX_ASSERT(p_cb->state != NRFX_DRV_STATE_UNINITIALIZED); bool ret_val = false; // If the event handler is used (interrupts are enabled), the state will // be changed in interrupt handler when the STOPPED event occurs. if (p_cb->state != NRFX_DRV_STATE_POWERED_ON) { ret_val = true; } // If interrupts are disabled, we must check the STOPPED event here. if (nrf_pwm_event_check(p_instance->p_registers, NRF_PWM_EVENT_STOPPED)) { p_cb->state = NRFX_DRV_STATE_INITIALIZED; NRFX_LOG_INFO("Disabled."); ret_val = true; } NRFX_LOG_INFO("%s returned %d.", __func__, ret_val); return ret_val; }