Lines Matching full:data
49 struct gpio_stepper_data *data = dev->data; in stepper_motor_set_coil_charge() local
54 half_step_lookup_table[data->coil_charge][i]); in stepper_motor_set_coil_charge()
61 struct gpio_stepper_data *data = dev->data; in increment_coil_charge() local
63 if (data->coil_charge == NUM_CONTROL_PINS * MAX_MICRO_STEP_RES - data->step_gap) { in increment_coil_charge()
64 data->coil_charge = 0; in increment_coil_charge()
66 data->coil_charge = data->coil_charge + data->step_gap; in increment_coil_charge()
72 struct gpio_stepper_data *data = dev->data; in decrement_coil_charge() local
74 if (data->coil_charge == 0) { in decrement_coil_charge()
75 data->coil_charge = NUM_CONTROL_PINS * MAX_MICRO_STEP_RES - data->step_gap; in decrement_coil_charge()
77 data->coil_charge = data->coil_charge - data->step_gap; in decrement_coil_charge()
99 struct gpio_stepper_data *data = dev->data; in update_coil_charge() local
101 if (data->direction == STEPPER_DIRECTION_POSITIVE) { in update_coil_charge()
103 data->actual_position++; in update_coil_charge()
104 } else if (data->direction == STEPPER_DIRECTION_NEGATIVE) { in update_coil_charge()
106 data->actual_position--; in update_coil_charge()
110 static void update_remaining_steps(struct gpio_stepper_data *data) in update_remaining_steps() argument
112 if (data->step_count > 0) { in update_remaining_steps()
113 data->step_count--; in update_remaining_steps()
114 (void)k_work_reschedule(&data->stepper_dwork, K_USEC(data->delay_in_us)); in update_remaining_steps()
115 } else if (data->step_count < 0) { in update_remaining_steps()
116 data->step_count++; in update_remaining_steps()
117 (void)k_work_reschedule(&data->stepper_dwork, K_USEC(data->delay_in_us)); in update_remaining_steps()
119 if (!data->callback) { in update_remaining_steps()
123 data->callback(data->dev, STEPPER_EVENT_STEPS_COMPLETED, data->event_cb_user_data); in update_remaining_steps()
129 struct gpio_stepper_data *data = dev->data; in update_direction_from_step_count() local
131 if (data->step_count > 0) { in update_direction_from_step_count()
132 data->direction = STEPPER_DIRECTION_POSITIVE; in update_direction_from_step_count()
133 } else if (data->step_count < 0) { in update_direction_from_step_count()
134 data->direction = STEPPER_DIRECTION_NEGATIVE; in update_direction_from_step_count()
142 struct gpio_stepper_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()
153 struct gpio_stepper_data *data = dev->data; in velocity_mode_task() local
157 (void)k_work_reschedule(&data->stepper_dwork, K_USEC(data->delay_in_us)); in velocity_mode_task()
163 struct gpio_stepper_data *data = in stepper_work_step_handler() local
166 K_SPINLOCK(&data->lock) { in stepper_work_step_handler()
167 switch (data->run_mode) { in stepper_work_step_handler()
169 position_mode_task(data->dev); in stepper_work_step_handler()
172 velocity_mode_task(data->dev); in stepper_work_step_handler()
175 LOG_WRN("Unsupported run mode %d", data->run_mode); in stepper_work_step_handler()
183 struct gpio_stepper_data *data = dev->data; in gpio_stepper_move_by() local
185 if (!data->is_enabled) { in gpio_stepper_move_by()
190 if (data->delay_in_us == 0) { in gpio_stepper_move_by()
194 K_SPINLOCK(&data->lock) { in gpio_stepper_move_by()
195 data->run_mode = STEPPER_RUN_MODE_POSITION; in gpio_stepper_move_by()
196 data->step_count = micro_steps; in gpio_stepper_move_by()
198 (void)k_work_reschedule(&data->stepper_dwork, K_NO_WAIT); in gpio_stepper_move_by()
205 struct gpio_stepper_data *data = dev->data; in gpio_stepper_set_reference_position() local
207 K_SPINLOCK(&data->lock) { in gpio_stepper_set_reference_position()
208 data->actual_position = position; in gpio_stepper_set_reference_position()
215 struct gpio_stepper_data *data = dev->data; in gpio_stepper_get_actual_position() local
217 K_SPINLOCK(&data->lock) { in gpio_stepper_get_actual_position()
218 *position = data->actual_position; in gpio_stepper_get_actual_position()
225 struct gpio_stepper_data *data = dev->data; in gpio_stepper_move_to() local
227 if (!data->is_enabled) { in gpio_stepper_move_to()
232 if (data->delay_in_us == 0) { in gpio_stepper_move_to()
236 K_SPINLOCK(&data->lock) { in gpio_stepper_move_to()
237 data->run_mode = STEPPER_RUN_MODE_POSITION; in gpio_stepper_move_to()
238 data->step_count = micro_steps - data->actual_position; in gpio_stepper_move_to()
240 (void)k_work_reschedule(&data->stepper_dwork, K_NO_WAIT); in gpio_stepper_move_to()
247 struct gpio_stepper_data *data = dev->data; in gpio_stepper_is_moving() local
249 *is_moving = k_work_delayable_is_pending(&data->stepper_dwork); in gpio_stepper_is_moving()
256 struct gpio_stepper_data *data = dev->data; in gpio_stepper_set_max_velocity() local
268 K_SPINLOCK(&data->lock) { in gpio_stepper_set_max_velocity()
269 data->delay_in_us = USEC_PER_SEC / velocity; in gpio_stepper_set_max_velocity()
278 struct gpio_stepper_data *data = dev->data; in gpio_stepper_run() local
280 if (!data->is_enabled) { in gpio_stepper_run()
285 K_SPINLOCK(&data->lock) { in gpio_stepper_run()
286 data->run_mode = STEPPER_RUN_MODE_VELOCITY; in gpio_stepper_run()
287 data->direction = direction; in gpio_stepper_run()
289 data->delay_in_us = USEC_PER_SEC / velocity; in gpio_stepper_run()
290 (void)k_work_reschedule(&data->stepper_dwork, K_NO_WAIT); in gpio_stepper_run()
292 (void)k_work_cancel_delayable(&data->stepper_dwork); in gpio_stepper_run()
301 struct gpio_stepper_data *data = dev->data; in gpio_stepper_set_micro_step_res() local
303 K_SPINLOCK(&data->lock) { in gpio_stepper_set_micro_step_res()
307 data->step_gap = MAX_MICRO_STEP_RES >> (micro_step_res - 1); in gpio_stepper_set_micro_step_res()
320 struct gpio_stepper_data *data = dev->data; in gpio_stepper_get_micro_step_res() local
321 *micro_step_res = MAX_MICRO_STEP_RES >> (data->step_gap - 1); in gpio_stepper_get_micro_step_res()
328 struct gpio_stepper_data *data = dev->data; in gpio_stepper_set_event_callback() local
330 K_SPINLOCK(&data->lock) { in gpio_stepper_set_event_callback()
331 data->callback = callback; in gpio_stepper_set_event_callback()
333 data->event_cb_user_data = user_data; in gpio_stepper_set_event_callback()
339 struct gpio_stepper_data *data = dev->data; in gpio_stepper_enable() local
341 K_SPINLOCK(&data->lock) { in gpio_stepper_enable()
343 data->is_enabled = enable; in gpio_stepper_enable()
346 (void)k_work_reschedule(&data->stepper_dwork, K_NO_WAIT); in gpio_stepper_enable()
348 (void)k_work_cancel_delayable(&data->stepper_dwork); in gpio_stepper_enable()
361 struct gpio_stepper_data *data = dev->data; in gpio_stepper_init() local
364 data->dev = dev; in gpio_stepper_init()
369 k_work_init_delayable(&data->stepper_dwork, stepper_work_step_handler); in gpio_stepper_init()