|
Zephyr Project API 4.1.0
A Scalable Open Source RTOS
|
Stepper Driver Interface. More...
Modules | |
| Trinamic Stepper Controller Interface | |
| Trinamic Stepper Controller Interface. | |
Macros | |
| #define | MICRO_STEP_RES_INDEX(res) LOG2(res) |
| Macro to calculate the index of the microstep resolution. | |
Enumerations | |
| enum | stepper_micro_step_resolution { STEPPER_MICRO_STEP_1 = 1 , STEPPER_MICRO_STEP_2 = 2 , STEPPER_MICRO_STEP_4 = 4 , STEPPER_MICRO_STEP_8 = 8 , STEPPER_MICRO_STEP_16 = 16 , STEPPER_MICRO_STEP_32 = 32 , STEPPER_MICRO_STEP_64 = 64 , STEPPER_MICRO_STEP_128 = 128 , STEPPER_MICRO_STEP_256 = 256 } |
| Stepper Motor micro-step resolution options. More... | |
| enum | stepper_direction { STEPPER_DIRECTION_NEGATIVE = 0 , STEPPER_DIRECTION_POSITIVE = 1 } |
| Stepper Motor direction options. More... | |
| enum | stepper_run_mode { STEPPER_RUN_MODE_HOLD = 0 , STEPPER_RUN_MODE_POSITION = 1 , STEPPER_RUN_MODE_VELOCITY = 2 } |
| Stepper Motor run mode options. More... | |
| enum | stepper_event { STEPPER_EVENT_STEPS_COMPLETED = 0 , STEPPER_EVENT_STALL_DETECTED = 1 , STEPPER_EVENT_LEFT_END_STOP_DETECTED = 2 , STEPPER_EVENT_RIGHT_END_STOP_DETECTED = 3 } |
| Stepper Events. More... | |
Functions | |
| int | stepper_enable (const struct device *dev, const bool enable) |
| Enable or disable stepper driver. | |
| int | stepper_set_micro_step_res (const struct device *dev, enum stepper_micro_step_resolution resolution) |
| Set the micro-step resolution in stepper driver. | |
| int | stepper_get_micro_step_res (const struct device *dev, enum stepper_micro_step_resolution *resolution) |
| Get the micro-step resolution in stepper driver. | |
| int | stepper_set_reference_position (const struct device *dev, int32_t value) |
| Set the reference position of the stepper. | |
| int | stepper_get_actual_position (const struct device *dev, int32_t *value) |
| Get the actual a.k.a reference position of the stepper. | |
| int | stepper_set_event_callback (const struct device *dev, stepper_event_callback_t callback, void *user_data) |
| Set the callback function to be called when a stepper event occurs. | |
| int | stepper_set_microstep_interval (const struct device *dev, uint64_t microstep_interval_ns) |
| Set the time interval between steps in nanoseconds. | |
| int | stepper_move_by (const struct device *dev, int32_t micro_steps) |
| Set the micro-steps to be moved from the current position i.e. | |
| int | stepper_move_to (const struct device *dev, int32_t micro_steps) |
| Set the absolute target position of the stepper. | |
| int | stepper_run (const struct device *dev, enum stepper_direction direction) |
| Run the stepper with a given step interval in a given direction. | |
| int | stepper_is_moving (const struct device *dev, bool *is_moving) |
| Check if the stepper is currently moving. | |
Stepper Driver Interface.
| #define MICRO_STEP_RES_INDEX | ( | res | ) | LOG2(res) |
#include <include/zephyr/drivers/stepper.h>
Macro to calculate the index of the microstep resolution.
| res | Microstep resolution |
| enum stepper_direction |
#include <include/zephyr/drivers/stepper.h>
Stepper Motor direction options.
| Enumerator | |
|---|---|
| STEPPER_DIRECTION_NEGATIVE | Negative direction. |
| STEPPER_DIRECTION_POSITIVE | Positive direction. |
| enum stepper_event |
#include <include/zephyr/drivers/stepper.h>
Stepper Events.
#include <include/zephyr/drivers/stepper.h>
Stepper Motor micro-step resolution options.
| enum stepper_run_mode |
#include <include/zephyr/drivers/stepper.h>
Stepper Motor run mode options.
| Enumerator | |
|---|---|
| STEPPER_RUN_MODE_HOLD | Hold Mode. |
| STEPPER_RUN_MODE_POSITION | Position Mode. |
| STEPPER_RUN_MODE_VELOCITY | Velocity Mode. |
#include <include/zephyr/drivers/stepper.h>
Enable or disable stepper driver.
Enabling the driver will energize the coils, however not set the stepper in motion. Disabling the driver will de-energize the coils.
| dev | pointer to the stepper driver instance |
| enable | Input enable or disable stepper driver |
| -EIO | Error during Enabling |
| 0 | Success |
#include <include/zephyr/drivers/stepper.h>
Get the actual a.k.a reference position of the stepper.
| dev | pointer to the stepper driver instance |
| value | The actual position to get in micro-steps |
| -EIO | General input / output error |
| -ENOSYS | If not implemented by device driver |
| 0 | Success |
| int stepper_get_micro_step_res | ( | const struct device * | dev, |
| enum stepper_micro_step_resolution * | resolution | ||
| ) |
#include <include/zephyr/drivers/stepper.h>
Get the micro-step resolution in stepper driver.
| dev | pointer to the stepper driver instance |
| resolution | micro-step resolution |
| -EIO | General input / output error |
| -ENOSYS | If not implemented by device driver |
| 0 | Success |
#include <include/zephyr/drivers/stepper.h>
Check if the stepper is currently moving.
| dev | pointer to the stepper driver instance |
| is_moving | Pointer to a boolean to store the moving status of the stepper |
| -EIO | General input / output error |
| -ENOSYS | If not implemented by device driver |
| 0 | Success |
#include <include/zephyr/drivers/stepper.h>
Set the micro-steps to be moved from the current position i.e.
relative movement
The stepper will move by the given number of micro-steps from the current position. This function is non-blocking.
| dev | pointer to the stepper driver instance |
| micro_steps | target micro-steps to be moved from the current position |
| -ECANCELED | If the stepper is disabled |
| -EIO | General input / output error |
| 0 | Success |
#include <include/zephyr/drivers/stepper.h>
Set the absolute target position of the stepper.
The stepper will move to the given micro-steps position from the reference position. This function is non-blocking.
| dev | pointer to the stepper driver instance |
| micro_steps | target position to set in micro-steps |
| -ECANCELED | If the stepper is disabled |
| -EIO | General input / output error |
| -ENOSYS | If not implemented by device driver |
| 0 | Success |
| int stepper_run | ( | const struct device * | dev, |
| enum stepper_direction | direction | ||
| ) |
#include <include/zephyr/drivers/stepper.h>
Run the stepper with a given step interval in a given direction.
The stepper shall be set into motion and run continuously until stalled or stopped using some other command, for instance, stepper_enable(false). This function is non-blocking.
| dev | pointer to the stepper driver instance |
| direction | The direction to set |
| -ECANCELED | If the stepper is disabled |
| -EIO | General input / output error |
| -ENOSYS | If not implemented by device driver |
| 0 | Success |
| int stepper_set_event_callback | ( | const struct device * | dev, |
| stepper_event_callback_t | callback, | ||
| void * | user_data | ||
| ) |
#include <include/zephyr/drivers/stepper.h>
Set the callback function to be called when a stepper event occurs.
| dev | pointer to the stepper driver instance |
| callback | Callback function to be called when a stepper event occurs passing NULL will disable the callback |
| user_data | User data to be passed to the callback function |
| -ENOSYS | If not implemented by device driver |
| 0 | Success |
| int stepper_set_micro_step_res | ( | const struct device * | dev, |
| enum stepper_micro_step_resolution | resolution | ||
| ) |
#include <include/zephyr/drivers/stepper.h>
Set the micro-step resolution in stepper driver.
| dev | pointer to the stepper driver instance |
| resolution | micro-step resolution |
| -EIO | General input / output error |
| -ENOSYS | If not implemented by device driver |
| -ENOTSUP | If the requested resolution is not supported |
| 0 | Success |
#include <include/zephyr/drivers/stepper.h>
Set the time interval between steps in nanoseconds.
| dev | pointer to the stepper driver instance |
| microstep_interval_ns | time interval between steps in nanoseconds |
| -EIO | General input / output error |
| -EINVAL | If the requested step interval is not supported |
| -ENOSYS | If not implemented by device driver |
| 0 | Success |
#include <include/zephyr/drivers/stepper.h>
Set the reference position of the stepper.
| dev | Pointer to the stepper driver instance. |
| value | The reference position to set in micro-steps. |
| -EIO | General input / output error |
| -ENOSYS | If not implemented by device driver |
| 0 | Success |