Zephyr API Documentation 4.4.0-rc1
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Stepper Hardware Driver

Interfaces for stepper hardware drivers. More...

Topics

 Stepper Hardware Driver Driver Backend API

Files

file  stepper.h
 Main header file for stepper hardware driver API.

Macros

#define MICRO_STEP_RES_INDEX(res)
 Macro to calculate the index of the microstep resolution.
#define VALID_MICRO_STEP_RES(res)

Typedefs

typedef void(* stepper_event_cb_t) (const struct device *dev, const enum stepper_event event, void *user_data)
 Callback function for stepper driver events.

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_event { STEPPER_EVENT_STALL_DETECTED = 0 , STEPPER_EVENT_FAULT_DETECTED = 1 }
 Stepper Hardware Driver Events. More...

Functions

int stepper_enable (const struct device *dev)
 Enable stepper hardware driver.
int stepper_disable (const struct device *dev)
 Disable stepper hardware driver.
int stepper_set_micro_step_res (const struct device *dev, enum stepper_micro_step_resolution res)
 Set the micro-step resolution in stepper hardware driver.
int stepper_get_micro_step_res (const struct device *dev, enum stepper_micro_step_resolution *res)
 Get the micro-step resolution in stepper hardware driver.
int stepper_set_event_cb (const struct device *dev, stepper_event_cb_t callback, void *user_data)
 Set the callback function to be called when a stepper_event occurs.

Detailed Description

Interfaces for stepper hardware drivers.

Since
4.0
Version
0.9.0

Macro Definition Documentation

◆ MICRO_STEP_RES_INDEX

#define MICRO_STEP_RES_INDEX ( res)

#include <zephyr/drivers/stepper/stepper.h>

Value:
LOG2(res)
#define LOG2(x)
Compute log2(x).
Definition util.h:879

Macro to calculate the index of the microstep resolution.

Parameters
resMicrostep resolution

◆ VALID_MICRO_STEP_RES

#define VALID_MICRO_STEP_RES ( res)

#include <zephyr/drivers/stepper/stepper.h>

Value:
((res) == STEPPER_MICRO_STEP_1 || (res) == STEPPER_MICRO_STEP_2 || \
(res) == STEPPER_MICRO_STEP_4 || (res) == STEPPER_MICRO_STEP_8 || \
(res) == STEPPER_MICRO_STEP_16 || (res) == STEPPER_MICRO_STEP_32 || \
@ STEPPER_MICRO_STEP_64
64 micro-steps per full step
Definition stepper.h:54
@ STEPPER_MICRO_STEP_4
4 micro-steps per full step
Definition stepper.h:46
@ STEPPER_MICRO_STEP_1
Full step resolution.
Definition stepper.h:42
@ STEPPER_MICRO_STEP_2
2 micro-steps per full step
Definition stepper.h:44
@ STEPPER_MICRO_STEP_256
256 micro-steps per full step
Definition stepper.h:58
@ STEPPER_MICRO_STEP_8
8 micro-steps per full step
Definition stepper.h:48
@ STEPPER_MICRO_STEP_16
16 micro-steps per full step
Definition stepper.h:50
@ STEPPER_MICRO_STEP_32
32 micro-steps per full step
Definition stepper.h:52
@ STEPPER_MICRO_STEP_128
128 micro-steps per full step
Definition stepper.h:56

Typedef Documentation

◆ stepper_event_cb_t

typedef void(* stepper_event_cb_t) (const struct device *dev, const enum stepper_event event, void *user_data)

#include <zephyr/drivers/stepper/stepper.h>

Callback function for stepper driver events.

Enumeration Type Documentation

◆ stepper_event

#include <zephyr/drivers/stepper/stepper.h>

Stepper Hardware Driver Events.

Enumerator
STEPPER_EVENT_STALL_DETECTED 

Stepper driver stall detected.

STEPPER_EVENT_FAULT_DETECTED 

Stepper driver fault detected.

◆ stepper_micro_step_resolution

#include <zephyr/drivers/stepper/stepper.h>

Stepper Motor micro-step resolution options.

Enumerator
STEPPER_MICRO_STEP_1 

Full step resolution.

STEPPER_MICRO_STEP_2 

2 micro-steps per full step

STEPPER_MICRO_STEP_4 

4 micro-steps per full step

STEPPER_MICRO_STEP_8 

8 micro-steps per full step

STEPPER_MICRO_STEP_16 

16 micro-steps per full step

STEPPER_MICRO_STEP_32 

32 micro-steps per full step

STEPPER_MICRO_STEP_64 

64 micro-steps per full step

STEPPER_MICRO_STEP_128 

128 micro-steps per full step

STEPPER_MICRO_STEP_256 

256 micro-steps per full step

Function Documentation

◆ stepper_disable()

int stepper_disable ( const struct device * dev)

#include <zephyr/drivers/stepper/stepper.h>

Disable stepper hardware driver.

Disabling the hw driver shall switch off the power stage and de-energize the coils.

Parameters
devpointer to the device structure for the driver instance.
Return values
-ENOTSUPDisabling of hw driver is not supported.
-EIOError during Disabling
0Success

◆ stepper_enable()

int stepper_enable ( const struct device * dev)

#include <zephyr/drivers/stepper/stepper.h>

Enable stepper hardware driver.

Enabling the driver shall switch on the power stage and energize the coils.

Parameters
devpointer to the device structure for the driver instance.
Return values
-EIOError during Enabling
0Success

◆ stepper_get_micro_step_res()

int stepper_get_micro_step_res ( const struct device * dev,
enum stepper_micro_step_resolution * res )

#include <zephyr/drivers/stepper/stepper.h>

Get the micro-step resolution in stepper hardware driver.

Parameters
devpointer to the device structure for the driver instance.
resmicro-step resolution
Return values
-EIOGeneral input / output error
0Success

◆ stepper_set_event_cb()

int stepper_set_event_cb ( const struct device * dev,
stepper_event_cb_t callback,
void * user_data )

#include <zephyr/drivers/stepper/stepper.h>

Set the callback function to be called when a stepper_event occurs.

Parameters
devpointer to the device structure for the driver instance.
callbackCallback function to be called when a stepper_event occurs passing NULL will disable the callback
user_dataUser data to be passed to the callback function
Return values
-ENOSYSIf not implemented by device driver
0Success

◆ stepper_set_micro_step_res()

int stepper_set_micro_step_res ( const struct device * dev,
enum stepper_micro_step_resolution res )

#include <zephyr/drivers/stepper/stepper.h>

Set the micro-step resolution in stepper hardware driver.

Parameters
devpointer to the device structure for the driver instance.
resmicro-step resolution
Return values
-EIOGeneral input / output error
-EINVALIf the requested resolution is invalid
-ENOTSUPIf the requested resolution is not supported
0Success