Lines Matching full:data
14 struct step_dir_stepper_common_data *data = dev->data; in step_dir_stepper_perform_step() local
17 switch (data->direction) { in step_dir_stepper_perform_step()
25 LOG_ERR("Unsupported direction: %d", data->direction); in step_dir_stepper_perform_step()
47 if (data->direction == STEPPER_DIRECTION_POSITIVE) { in step_dir_stepper_perform_step()
48 data->actual_position++; in step_dir_stepper_perform_step()
50 data->actual_position--; in step_dir_stepper_perform_step()
58 struct step_dir_stepper_common_data *data = dev->data; in stepper_trigger_callback() local
60 if (!data->callback) { in stepper_trigger_callback()
66 data->callback(dev, event, data->event_cb_user_data); in stepper_trigger_callback()
72 int ret = k_msgq_put(&data->event_msgq, &event, K_NO_WAIT); in stepper_trigger_callback()
78 ret = k_work_submit(&data->event_callback_work); in stepper_trigger_callback()
90 struct step_dir_stepper_common_data *data = in stepper_work_event_handler() local
95 ret = k_msgq_get(&data->event_msgq, &event, K_NO_WAIT); in stepper_work_event_handler()
101 if (data->callback != NULL) { in stepper_work_event_handler()
102 data->callback(data->dev, event, data->event_cb_user_data); in stepper_work_event_handler()
106 if (k_msgq_num_used_get(&data->event_msgq) > 0) { in stepper_work_event_handler()
112 static void update_remaining_steps(struct step_dir_stepper_common_data *data) in update_remaining_steps() argument
114 const struct step_dir_stepper_common_config *config = data->dev->config; in update_remaining_steps()
116 if (data->step_count > 0) { in update_remaining_steps()
117 data->step_count--; in update_remaining_steps()
118 } else if (data->step_count < 0) { in update_remaining_steps()
119 data->step_count++; in update_remaining_steps()
121 stepper_trigger_callback(data->dev, STEPPER_EVENT_STEPS_COMPLETED); in update_remaining_steps()
122 config->timing_source->stop(data->dev); in update_remaining_steps()
128 struct step_dir_stepper_common_data *data = dev->data; in update_direction_from_step_count() local
130 if (data->step_count > 0) { in update_direction_from_step_count()
131 data->direction = STEPPER_DIRECTION_POSITIVE; in update_direction_from_step_count()
132 } else if (data->step_count < 0) { in update_direction_from_step_count()
133 data->direction = STEPPER_DIRECTION_NEGATIVE; in update_direction_from_step_count()
141 struct step_dir_stepper_common_data *data = dev->data; in position_mode_task() local
144 if (data->step_count) { in position_mode_task()
148 update_remaining_steps(dev->data); in position_mode_task()
150 if (config->timing_source->needs_reschedule(dev) && data->step_count != 0) { in position_mode_task()
168 struct step_dir_stepper_common_data *data = dev->data; in stepper_handle_timing_signal() local
170 K_SPINLOCK(&data->lock) { in stepper_handle_timing_signal()
171 switch (data->run_mode) { in stepper_handle_timing_signal()
179 LOG_WRN("Unsupported run mode: %d", data->run_mode); in stepper_handle_timing_signal()
216 struct step_dir_stepper_common_data *data = dev->data; in step_dir_stepper_common_init() local
218 k_msgq_init(&data->event_msgq, data->event_msgq_buffer, sizeof(enum stepper_event), in step_dir_stepper_common_init()
220 k_work_init(&data->event_callback_work, stepper_work_event_handler); in step_dir_stepper_common_init()
228 struct step_dir_stepper_common_data *data = dev->data; in step_dir_stepper_common_move_by() local
231 if (data->max_velocity == 0) { in step_dir_stepper_common_move_by()
236 K_SPINLOCK(&data->lock) { in step_dir_stepper_common_move_by()
237 data->run_mode = STEPPER_RUN_MODE_POSITION; in step_dir_stepper_common_move_by()
238 data->step_count = micro_steps; in step_dir_stepper_common_move_by()
239 config->timing_source->update(dev, data->max_velocity); in step_dir_stepper_common_move_by()
249 struct step_dir_stepper_common_data *data = dev->data; in step_dir_stepper_common_set_max_velocity() local
262 K_SPINLOCK(&data->lock) { in step_dir_stepper_common_set_max_velocity()
263 data->max_velocity = velocity; in step_dir_stepper_common_set_max_velocity()
272 struct step_dir_stepper_common_data *data = dev->data; in step_dir_stepper_common_set_reference_position() local
274 K_SPINLOCK(&data->lock) { in step_dir_stepper_common_set_reference_position()
275 data->actual_position = value; in step_dir_stepper_common_set_reference_position()
283 struct step_dir_stepper_common_data *data = dev->data; in step_dir_stepper_common_get_actual_position() local
285 K_SPINLOCK(&data->lock) { in step_dir_stepper_common_get_actual_position()
286 *value = data->actual_position; in step_dir_stepper_common_get_actual_position()
294 struct step_dir_stepper_common_data *data = dev->data; in step_dir_stepper_common_move_to() local
297 if (data->max_velocity == 0) { in step_dir_stepper_common_move_to()
302 K_SPINLOCK(&data->lock) { in step_dir_stepper_common_move_to()
303 data->run_mode = STEPPER_RUN_MODE_POSITION; in step_dir_stepper_common_move_to()
304 data->step_count = value - data->actual_position; in step_dir_stepper_common_move_to()
305 config->timing_source->update(dev, data->max_velocity); in step_dir_stepper_common_move_to()
324 struct step_dir_stepper_common_data *data = dev->data; in step_dir_stepper_common_run() local
327 K_SPINLOCK(&data->lock) { in step_dir_stepper_common_run()
328 data->run_mode = STEPPER_RUN_MODE_VELOCITY; in step_dir_stepper_common_run()
329 data->direction = direction; in step_dir_stepper_common_run()
330 data->max_velocity = velocity; in step_dir_stepper_common_run()
345 struct step_dir_stepper_common_data *data = dev->data; in step_dir_stepper_common_set_event_callback() local
347 data->callback = callback; in step_dir_stepper_common_set_event_callback()
348 data->event_cb_user_data = user_data; in step_dir_stepper_common_set_event_callback()