Lines Matching full:capture
83 struct mcpwm_esp32_capture_config capture; member
220 /* Capture prescaler is disabled by default (equals 1) */ in mcpwm_esp32_get_cycles_per_sec()
295 struct mcpwm_esp32_capture_config *capture = &channel->capture; in mcpwm_esp32_configure_capture() local
303 LOG_ERR("PWM capture only supported on channels 6, 7 and 8"); in mcpwm_esp32_configure_capture()
307 if (data->hal.dev->cap_chn_cfg[capture->capture_signal].capn_en) { in mcpwm_esp32_configure_capture()
308 LOG_ERR("PWM Capture already in progress"); in mcpwm_esp32_configure_capture()
313 LOG_ERR("No PWM capture type specified"); in mcpwm_esp32_configure_capture()
318 capture->capture_signal = channel->idx - CAPTURE_CHANNEL_IDX; in mcpwm_esp32_configure_capture()
319 capture->callback = cb; in mcpwm_esp32_configure_capture()
320 capture->user_data = user_data; in mcpwm_esp32_configure_capture()
321 capture->capture_period = (flags & PWM_CAPTURE_TYPE_PERIOD); in mcpwm_esp32_configure_capture()
322 capture->capture_pulse = (flags & PWM_CAPTURE_TYPE_PULSE); in mcpwm_esp32_configure_capture()
323 capture->continuous = (flags & PWM_CAPTURE_MODE_CONTINUOUS); in mcpwm_esp32_configure_capture()
333 struct mcpwm_esp32_capture_config *capture = &channel->capture; in mcpwm_esp32_disable_capture() local
341 LOG_ERR("PWM capture only supported on channels 6, 7 and 8"); in mcpwm_esp32_disable_capture()
345 mcpwm_ll_capture_enable_channel(data->hal.dev, capture->capture_signal, false); in mcpwm_esp32_disable_capture()
346 mcpwm_ll_intr_enable(data->hal.dev, MCPWM_LL_EVENT_CAPTURE(capture->capture_signal), false); in mcpwm_esp32_disable_capture()
356 struct mcpwm_esp32_capture_config *capture = &channel->capture; in mcpwm_esp32_enable_capture() local
363 if (!capture->callback) { in mcpwm_esp32_enable_capture()
364 LOG_ERR("Capture not configured"); in mcpwm_esp32_enable_capture()
369 LOG_ERR("PWM capture only supported on channels 6, 7 and 8"); in mcpwm_esp32_enable_capture()
373 if (data->hal.dev->cap_chn_cfg[capture->capture_signal].capn_en) { in mcpwm_esp32_enable_capture()
374 LOG_ERR("PWM Capture already in progress"); in mcpwm_esp32_enable_capture()
379 * Capture prescale is different from other modules as it is applied to the input in mcpwm_esp32_enable_capture()
392 mcpwm_ll_capture_enable_channel(data->hal.dev, capture->capture_signal, true); in mcpwm_esp32_enable_capture()
393 mcpwm_ll_capture_enable_negedge(data->hal.dev, capture->capture_signal, in mcpwm_esp32_enable_capture()
395 mcpwm_ll_capture_enable_posedge(data->hal.dev, capture->capture_signal, in mcpwm_esp32_enable_capture()
397 mcpwm_ll_capture_set_prescale(data->hal.dev, capture->capture_signal, in mcpwm_esp32_enable_capture()
400 mcpwm_ll_intr_enable(data->hal.dev, MCPWM_LL_EVENT_CAPTURE(capture->capture_signal), true); in mcpwm_esp32_enable_capture()
401 mcpwm_ll_intr_clear_status(data->hal.dev, MCPWM_LL_EVENT_CAPTURE(capture->capture_signal)); in mcpwm_esp32_enable_capture()
403 capture->skip_irq = 0; in mcpwm_esp32_enable_capture()
470 struct mcpwm_esp32_capture_config *capture; in mcpwm_esp32_isr() local
487 capture = &channel->capture; in mcpwm_esp32_isr()
492 if (capture->skip_irq < SKIP_IRQ_NUM) { in mcpwm_esp32_isr()
493 capture->capture_data[capture->skip_irq].value = in mcpwm_esp32_isr()
494 mcpwm_ll_capture_get_value(data->hal.dev, capture->capture_signal); in mcpwm_esp32_isr()
495 capture->capture_data[capture->skip_irq].edge = in mcpwm_esp32_isr()
496 mcpwm_ll_capture_get_edge(data->hal.dev, capture->capture_signal) == in mcpwm_esp32_isr()
500 capture->skip_irq++; in mcpwm_esp32_isr()
504 * The capture timer is a 32-bit counter incrementing continuously, once enabled. in mcpwm_esp32_isr()
507 capture->period = channel->inverted ? in mcpwm_esp32_isr()
508 capture->capture_data[0].edge == MCPWM_NEG_EDGE in mcpwm_esp32_isr()
509 ? (capture->capture_data[2].value - capture->capture_data[0].value) in mcpwm_esp32_isr()
510 : (capture->capture_data[3].value - capture->capture_data[1].value) in mcpwm_esp32_isr()
511 : capture->capture_data[0].edge == MCPWM_POS_EDGE in mcpwm_esp32_isr()
512 ? (capture->capture_data[2].value - capture->capture_data[0].value) in mcpwm_esp32_isr()
513 : (capture->capture_data[3].value - capture->capture_data[1].value); in mcpwm_esp32_isr()
515 capture->pulse = channel->inverted ? in mcpwm_esp32_isr()
516 capture->capture_data[0].edge == MCPWM_NEG_EDGE in mcpwm_esp32_isr()
517 ? (capture->capture_data[1].value - capture->capture_data[0].value) in mcpwm_esp32_isr()
518 : (capture->capture_data[2].value - capture->capture_data[1].value) in mcpwm_esp32_isr()
519 : capture->capture_data[0].edge == MCPWM_POS_EDGE in mcpwm_esp32_isr()
520 ? (capture->capture_data[1].value - capture->capture_data[0].value) in mcpwm_esp32_isr()
521 : (capture->capture_data[2].value - capture->capture_data[1].value); in mcpwm_esp32_isr()
523 capture->skip_irq = 0; in mcpwm_esp32_isr()
524 if (!capture->continuous) { in mcpwm_esp32_isr()
528 if (capture->callback) { in mcpwm_esp32_isr()
529 capture->callback(dev, capture->capture_signal + CAPTURE_CHANNEL_IDX, in mcpwm_esp32_isr()
530 capture->capture_period ? capture->period : 0u, in mcpwm_esp32_isr()
531 capture->capture_pulse ? capture->pulse : 0u, 0u, in mcpwm_esp32_isr()
532 capture->user_data); in mcpwm_esp32_isr()