Lines Matching full:capture
25 /* PWM capture operates on channel pairs */
60 struct mcux_ftm_capture_data capture[MAX_CAPTURE_PAIRS]; member
94 LOG_ERR("Cannot set PWM, capture in progress on pair %d", pair); in mcux_ftm_set_cycles()
113 LOG_ERR("Cannot change period, capture in progress"); in mcux_ftm_set_cycles()
158 LOG_ERR("PWM capture only supported on even channels"); in mcux_ftm_configure_capture()
162 if (pair >= ARRAY_SIZE(data->capture)) { in mcux_ftm_configure_capture()
168 LOG_ERR("Capture already active on channel pair %d", pair); in mcux_ftm_configure_capture()
173 LOG_ERR("No capture type specified"); in mcux_ftm_configure_capture()
178 LOG_ERR("Cannot capture both period and pulse width"); in mcux_ftm_configure_capture()
182 data->capture[pair].callback = cb; in mcux_ftm_configure_capture()
183 data->capture[pair].user_data = user_data; in mcux_ftm_configure_capture()
184 param = &data->capture[pair].param; in mcux_ftm_configure_capture()
193 data->capture[pair].pulse_capture = false; in mcux_ftm_configure_capture()
203 data->capture[pair].pulse_capture = true; in mcux_ftm_configure_capture()
224 LOG_ERR("PWM capture only supported on even channels"); in mcux_ftm_enable_capture()
228 if (pair >= ARRAY_SIZE(data->capture)) { in mcux_ftm_enable_capture()
233 if (!data->capture[pair].callback) { in mcux_ftm_enable_capture()
234 LOG_ERR("PWM capture not configured"); in mcux_ftm_enable_capture()
239 LOG_ERR("Capture already active on channel pair %d", pair); in mcux_ftm_enable_capture()
246 FTM_SetupDualEdgeCapture(config->base, pair, &data->capture[pair].param, in mcux_ftm_enable_capture()
262 LOG_ERR("PWM capture only supported on even channels"); in mcux_ftm_disable_capture()
266 if (pair >= ARRAY_SIZE(data->capture)) { in mcux_ftm_disable_capture()
274 /* Clear Dual Edge Capture Enable bit */ in mcux_ftm_disable_capture()
286 struct mcux_ftm_capture_data *capture; in mcux_ftm_capture_first_edge() local
289 __ASSERT_NO_MSG(pair < ARRAY_SIZE(data->capture)); in mcux_ftm_capture_first_edge()
290 capture = &data->capture[pair]; in mcux_ftm_capture_first_edge()
294 capture->first_edge_cnt = cnt; in mcux_ftm_capture_first_edge()
295 capture->first_edge_overflows = data->overflows; in mcux_ftm_capture_first_edge()
296 capture->first_edge_overflow = overflow; in mcux_ftm_capture_first_edge()
308 struct mcux_ftm_capture_data *capture; in mcux_ftm_capture_second_edge() local
316 __ASSERT_NO_MSG(pair < ARRAY_SIZE(data->capture)); in mcux_ftm_capture_second_edge()
317 capture = &data->capture[pair]; in mcux_ftm_capture_second_edge()
322 if (capture->pulse_capture) { in mcux_ftm_capture_second_edge()
323 /* Clear both edge flags for pulse capture to capture first edge overflow counter */ in mcux_ftm_capture_second_edge()
326 /* Only clear second edge flag for period capture as next first edge is this edge */ in mcux_ftm_capture_second_edge()
330 if (unlikely(capture->first_edge_overflow && first_cnv > capture->first_edge_cnt)) { in mcux_ftm_capture_second_edge()
332 capture->first_edge_overflows--; in mcux_ftm_capture_second_edge()
340 overflows = second_edge_overflows - capture->first_edge_overflows; in mcux_ftm_capture_second_edge()
361 pair, capture->first_edge_overflows, second_edge_overflows, overflows, first_cnv, in mcux_ftm_capture_second_edge()
364 if (capture->pulse_capture) { in mcux_ftm_capture_second_edge()
365 capture->callback(dev, pair, 0, cycles, status, in mcux_ftm_capture_second_edge()
366 capture->user_data); in mcux_ftm_capture_second_edge()
368 capture->callback(dev, pair, cycles, 0, status, in mcux_ftm_capture_second_edge()
369 capture->user_data); in mcux_ftm_capture_second_edge()
372 if (capture->param.mode == kFTM_OneShot) { in mcux_ftm_capture_second_edge()
373 /* One-shot capture done */ in mcux_ftm_capture_second_edge()
375 } else if (capture->pulse_capture) { in mcux_ftm_capture_second_edge()
376 /* Prepare for first edge of next pulse capture */ in mcux_ftm_capture_second_edge()
379 /* First edge of next period capture is second edge of this capture (this edge) */ in mcux_ftm_capture_second_edge()
380 capture->first_edge_cnt = cnt; in mcux_ftm_capture_second_edge()
381 capture->first_edge_overflows = second_edge_overflows; in mcux_ftm_capture_second_edge()
382 capture->first_edge_overflow = false; in mcux_ftm_capture_second_edge()