/* This function is called on interrupt after duty set.  */
void pwm_ready_tick(nrf_timer_event_t event_type, void *p_context)
/* This function is called on interrupt after duty set.  */
void pwm_ready_tick(nrf_timer_event_t event_type, void *p_context)
{
    uint32_t timer_instance_id = (uint32_t)p_context;
    uint8_t disable = 1;
    for (uint8_t channel = 0; channel < APP_PWM_CHANNELS_PER_INSTANCE; ++channel)
    {
        if (m_pwm_ready_counter[timer_instance_id][channel])
        {
            --m_pwm_ready_counter[timer_instance_id][channel];
            if (!m_pwm_ready_counter[timer_instance_id][channel])
            {
                app_pwm_cb_t * p_cb = m_instances[timer_instance_id]->p_cb;
                p_cb->p_ready_callback(timer_instance_id);
            }
            else
            {
                disable = 0;
            }
        }
    }
    if (disable)
    {
        pwm_irq_disable(m_instances[timer_instance_id]);
    }
}