12#ifndef ZEPHYR_INCLUDE_DRIVERS_STEPPER_CTRL_H_
13#define ZEPHYR_INCLUDE_DRIVERS_STEPPER_CTRL_H_
119 const uint64_t microstep_interval_ns);
227static inline int z_impl_stepper_ctrl_set_reference_position(
const struct device *dev,
230 __ASSERT_NO_MSG(dev !=
NULL);
234 return DEVICE_API_GET(stepper_ctrl, dev)->set_reference_position(dev, value);
253static inline int z_impl_stepper_ctrl_get_actual_position(
const struct device *dev,
int32_t *value)
255 __ASSERT_NO_MSG(dev !=
NULL);
256 __ASSERT_NO_MSG(value !=
NULL);
260 return DEVICE_API_GET(stepper_ctrl, dev)->get_actual_position(dev, value);
278static inline int z_impl_stepper_ctrl_set_event_cb(
const struct device *dev,
282 __ASSERT_NO_MSG(dev !=
NULL);
286 return DEVICE_API_GET(stepper_ctrl, dev)->set_event_cb(dev, callback, user_data);
304 const uint64_t microstep_interval_ns);
306static inline int z_impl_stepper_ctrl_set_microstep_interval(
const struct device *dev,
307 const uint64_t microstep_interval_ns)
309 __ASSERT_NO_MSG(dev !=
NULL);
313 return DEVICE_API_GET(stepper_ctrl, dev)->set_microstep_interval(dev,
314 microstep_interval_ns);
330static inline int z_impl_stepper_ctrl_configure_ramp(
const struct device *dev,
333 __ASSERT_NO_MSG(dev !=
NULL);
334 __ASSERT_NO_MSG(ramp !=
NULL);
339 return DEVICE_API_GET(stepper_ctrl, dev)->configure_ramp(dev, ramp);
356static inline int z_impl_stepper_ctrl_move_by(
const struct device *dev,
const int32_t micro_steps)
358 __ASSERT_NO_MSG(dev !=
NULL);
359 return DEVICE_API_GET(stepper_ctrl, dev)->move_by(dev, micro_steps);
377static inline int z_impl_stepper_ctrl_move_to(
const struct device *dev,
const int32_t micro_steps)
379 __ASSERT_NO_MSG(dev !=
NULL);
380 return DEVICE_API_GET(stepper_ctrl, dev)->move_to(dev, micro_steps);
401static inline int z_impl_stepper_ctrl_run(
const struct device *dev,
404 __ASSERT_NO_MSG(dev !=
NULL);
423static inline int z_impl_stepper_ctrl_stop(
const struct device *dev)
425 __ASSERT_NO_MSG(dev !=
NULL);
444static inline int z_impl_stepper_ctrl_is_moving(
const struct device *dev,
bool *is_moving)
446 __ASSERT_NO_MSG(dev !=
NULL);
447 __ASSERT_NO_MSG(is_moving !=
NULL);
451 return DEVICE_API_GET(stepper_ctrl, dev)->is_moving(dev, is_moving);
462#include <zephyr/syscalls/stepper_ctrl.h>
#define DEVICE_API_GET(_class, _dev)
Expands to the pointer of a device's API for a given class.
Definition device.h:1375
int(* stepper_ctrl_get_actual_position_t)(const struct device *dev, int32_t *value)
Get the actual a.k.a reference position of the stepper motion controller.
Definition stepper_ctrl.h:103
int(* stepper_ctrl_set_reference_position_t)(const struct device *dev, const int32_t value)
Set the reference position of the stepper motion controller.
Definition stepper_ctrl.h:96
int(* stepper_ctrl_set_event_cb_t)(const struct device *dev, stepper_ctrl_event_callback_t callback, void *user_data)
Set the callback function to be called when a stepper motion controller event occurs.
Definition stepper_ctrl.h:110
int(* stepper_ctrl_run_t)(const struct device *dev, const enum stepper_ctrl_direction direction)
Run the stepper with a given step interval in a given direction.
Definition stepper_ctrl.h:148
int(* stepper_ctrl_configure_ramp_t)(const struct device *dev, const struct stepper_ctrl_ramp *ramp)
Configure the ramp parameters for the stepper motion controller.
Definition stepper_ctrl.h:126
int(* stepper_ctrl_move_to_t)(const struct device *dev, const int32_t micro_steps)
Move the stepper to an absolute position in micro-steps.
Definition stepper_ctrl.h:141
int(* stepper_ctrl_move_by_t)(const struct device *dev, const int32_t micro_steps)
Move the stepper relatively by a given number of micro-steps.
Definition stepper_ctrl.h:134
int(* stepper_ctrl_set_microstep_interval_t)(const struct device *dev, const uint64_t microstep_interval_ns)
Set the time interval between steps in nanoseconds.
Definition stepper_ctrl.h:118
int(* stepper_ctrl_is_moving_t)(const struct device *dev, bool *is_moving)
Is the target position fo the stepper reached.
Definition stepper_ctrl.h:163
int(* stepper_ctrl_stop_t)(const struct device *dev)
Stop the stepper.
Definition stepper_ctrl.h:156
stepper_ctrl_direction
Stepper Motion Controller direction options.
Definition stepper_ctrl.h:35
int stepper_ctrl_set_microstep_interval(const struct device *dev, const uint64_t microstep_interval_ns)
Set the time interval between steps in nanoseconds with immediate effect.
int stepper_ctrl_run(const struct device *dev, const enum stepper_ctrl_direction direction)
Run the stepper with a given step interval in a given direction.
stepper_ctrl_event
Stepper Motion Controller Events.
Definition stepper_ctrl.h:57
void(* stepper_ctrl_event_callback_t)(const struct device *dev, const enum stepper_ctrl_event event, void *user_data)
Callback function for stepper motion controller events.
Definition stepper_ctrl.h:83
int stepper_ctrl_stop(const struct device *dev)
Stop the stepper.
stepper_ctrl_run_mode
Stepper Motion Controller run mode options.
Definition stepper_ctrl.h:45
int stepper_ctrl_move_by(const struct device *dev, const int32_t micro_steps)
Set the micro-steps to be moved from the current position i.e.
int stepper_ctrl_move_to(const struct device *dev, const int32_t micro_steps)
Set the absolute target position of the stepper.
int stepper_ctrl_set_event_cb(const struct device *dev, stepper_ctrl_event_callback_t callback, void *user_data)
Set the callback function to be called when a stepper motion controller event occurs.
int stepper_ctrl_configure_ramp(const struct device *dev, const struct stepper_ctrl_ramp *ramp)
Configure the ramp for the stepper motion controller.
int stepper_ctrl_set_reference_position(const struct device *dev, const int32_t value)
Set the reference position.
int stepper_ctrl_is_moving(const struct device *dev, bool *is_moving)
Check if the stepper is currently moving.
int stepper_ctrl_get_actual_position(const struct device *dev, int32_t *value)
Get the actual step count.
@ STEPPER_CTRL_DIRECTION_POSITIVE
Positive direction.
Definition stepper_ctrl.h:39
@ STEPPER_CTRL_DIRECTION_NEGATIVE
Negative direction.
Definition stepper_ctrl.h:37
@ STEPPER_CTRL_EVENT_RIGHT_END_STOP_DETECTED
Right end switch status changes to pressed.
Definition stepper_ctrl.h:63
@ STEPPER_CTRL_EVENT_LEFT_END_STOP_DETECTED
Left end switch status changes to pressed.
Definition stepper_ctrl.h:61
@ STEPPER_CTRL_EVENT_STEPS_COMPLETED
Steps set using move_by or move_to have been executed.
Definition stepper_ctrl.h:59
@ STEPPER_CTRL_EVENT_STOPPED
Stepper has stopped.
Definition stepper_ctrl.h:65
@ STEPPER_CTRL_RUN_MODE_HOLD
Hold Mode.
Definition stepper_ctrl.h:47
@ STEPPER_CTRL_RUN_MODE_POSITION
Position Mode.
Definition stepper_ctrl.h:49
@ STEPPER_CTRL_RUN_MODE_VELOCITY
Velocity Mode.
Definition stepper_ctrl.h:51
#define ENOSYS
Function not implemented.
Definition errno.h:82
#define NULL
Definition iar_missing_defs.h:20
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__INT32_TYPE__ int32_t
Definition stdint.h:74
__UINT64_TYPE__ uint64_t
Definition stdint.h:91
Runtime device structure (in ROM) per driver instance.
Definition device.h:513
<span class="mlabel">Driver Operations</span> Stepper Motion Controller driver operations
Definition stepper_ctrl.h:168
stepper_ctrl_stop_t stop
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition stepper_ctrl.h:204
stepper_ctrl_move_by_t move_by
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition stepper_ctrl.h:192
stepper_ctrl_set_reference_position_t set_reference_position
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition stepper_ctrl.h:172
stepper_ctrl_is_moving_t is_moving
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition stepper_ctrl.h:208
stepper_ctrl_set_event_cb_t set_event_cb
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition stepper_ctrl.h:180
stepper_ctrl_set_microstep_interval_t set_microstep_interval
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition stepper_ctrl.h:184
stepper_ctrl_run_t run
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition stepper_ctrl.h:200
stepper_ctrl_move_to_t move_to
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition stepper_ctrl.h:196
stepper_ctrl_configure_ramp_t configure_ramp
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition stepper_ctrl.h:188
stepper_ctrl_get_actual_position_t get_actual_position
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition stepper_ctrl.h:176
Steper Motion Controller Ramp Parameters.
Definition stepper_ctrl.h:71
uint32_t deceleration_max
Deceleration in micro_steps/s²
Definition stepper_ctrl.h:77
uint32_t acceleration_max
Acceleration in micro_steps/s²
Definition stepper_ctrl.h:73
uint32_t speed_max
Maximum speed in micro_steps/s.
Definition stepper_ctrl.h:75