Zephyr Project API 4.0.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Trinamic Stepper Controller Interface

Trinamic Stepper Controller Interface. More...

Data Structures

struct  tmc_ramp_generator_data
 Trinamic Stepper Ramp Generator data. More...
 

Macros

#define TMC_RAMP_VSTART_MAX   GENMASK(17, 0)
 Trinamic stepper controller ramp generator data limits.
 
#define TMC_RAMP_VSTART_MIN   0
 
#define TMC_RAMP_V1_MAX   GENMASK(19, 0)
 
#define TMC_RAMP_V1_MIN   0
 
#define TMC_RAMP_VMAX_MAX   (GENMASK(22, 0) - 512)
 
#define TMC_RAMP_VMAX_MIN   0
 
#define TMC_RAMP_A1_MAX   GENMASK(15, 0)
 
#define TMC_RAMP_A1_MIN   0
 
#define TMC_RAMP_AMAX_MAX   GENMASK(15, 0)
 
#define TMC_RAMP_AMAX_MIN   0
 
#define TMC_RAMP_D1_MAX   GENMASK(15, 0)
 
#define TMC_RAMP_D1_MIN   1
 
#define TMC_RAMP_DMAX_MAX   GENMASK(15, 0)
 
#define TMC_RAMP_DMAX_MIN   0
 
#define TMC_RAMP_VSTOP_MAX   GENMASK(17, 0)
 
#define TMC_RAMP_VSTOP_MIN   1
 
#define TMC_RAMP_TZEROWAIT_MAX   (GENMASK(15, 0) - 512)
 
#define TMC_RAMP_TZEROWAIT_MIN   0
 
#define TMC_RAMP_VCOOLTHRS_MAX   GENMASK(22, 0)
 
#define TMC_RAMP_VCOOLTHRS_MIN   0
 
#define TMC_RAMP_VHIGH_MAX   GENMASK(22, 0)
 
#define TMC_RAMP_VHIGH_MIN   0
 
#define TMC_RAMP_IHOLD_IRUN_MAX   GENMASK(4, 0)
 
#define TMC_RAMP_IHOLD_IRUN_MIN   0
 
#define TMC_RAMP_IHOLDDELAY_MAX   GENMASK(3, 0)
 
#define TMC_RAMP_IHOLDDELAY_MIN   0
 
#define TMC_RAMP_VACTUAL_SHIFT   22
 
#define CHECK_RAMP_DT_DATA(node)
 Check if Ramp DT data is within limits.
 
#define TMC_RAMP_DT_SPEC_GET(node)
 Get Trinamic Stepper Ramp Generator data from DT.
 

Functions

int tmc5041_stepper_set_ramp (const struct device *dev, const struct tmc_ramp_generator_data *ramp_data)
 Configure Trinamic Stepper Ramp Generator.
 

Detailed Description

Trinamic Stepper Controller Interface.

Macro Definition Documentation

◆ CHECK_RAMP_DT_DATA

#define CHECK_RAMP_DT_DATA (   node)

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

Value:
COND_CODE_1(DT_PROP_EXISTS(node, vstart), \
BUILD_ASSERT(IN_RANGE(DT_PROP(node, vstart), TMC_RAMP_VSTART_MIN, \
TMC_RAMP_VSTART_MAX), "vstart out of range"), ()); \
COND_CODE_1(DT_PROP_EXISTS(node, v1), \
BUILD_ASSERT(IN_RANGE(DT_PROP(node, v1), TMC_RAMP_V1_MIN, \
TMC_RAMP_V1_MAX), "v1 out of range"), ()); \
COND_CODE_1(DT_PROP_EXISTS(node, vmax), \
BUILD_ASSERT(IN_RANGE(DT_PROP(node, vmax), TMC_RAMP_VMAX_MIN, \
TMC_RAMP_VMAX_MAX), "vmax out of range"), ()); \
COND_CODE_1(DT_PROP_EXISTS(node, a1), \
BUILD_ASSERT(IN_RANGE(DT_PROP(node, a1), TMC_RAMP_A1_MIN, \
TMC_RAMP_A1_MAX), "a1 out of range"), ()); \
COND_CODE_1(DT_PROP_EXISTS(node, amax), \
BUILD_ASSERT(IN_RANGE(DT_PROP(node, amax), TMC_RAMP_AMAX_MIN, \
TMC_RAMP_AMAX_MAX), "amax out of range"), ()); \
COND_CODE_1(DT_PROP_EXISTS(node, d1), \
BUILD_ASSERT(IN_RANGE(DT_PROP(node, d1), TMC_RAMP_D1_MIN, \
TMC_RAMP_D1_MAX), "d1 out of range"), ()); \
COND_CODE_1(DT_PROP_EXISTS(node, dmax), \
BUILD_ASSERT(IN_RANGE(DT_PROP(node, dmax), TMC_RAMP_DMAX_MIN, \
TMC_RAMP_DMAX_MAX), "dmax out of range"), ()); \
COND_CODE_1(DT_PROP_EXISTS(node, vstop), \
BUILD_ASSERT(IN_RANGE(DT_PROP(node, vstop), TMC_RAMP_VSTOP_MIN, \
TMC_RAMP_VSTOP_MAX), "vstop out of range"), ()); \
COND_CODE_1(DT_PROP_EXISTS(node, tzerowait), \
BUILD_ASSERT(IN_RANGE(DT_PROP(node, tzerowait), TMC_RAMP_TZEROWAIT_MIN, \
TMC_RAMP_TZEROWAIT_MAX), "tzerowait out of range"), ()); \
COND_CODE_1(DT_PROP_EXISTS(node, vcoolthrs), \
BUILD_ASSERT(IN_RANGE(DT_PROP(node, vcoolthrs), TMC_RAMP_VCOOLTHRS_MIN, \
TMC_RAMP_VCOOLTHRS_MAX), "vcoolthrs out of range"), ()); \
COND_CODE_1(DT_PROP_EXISTS(node, vhigh), \
BUILD_ASSERT(IN_RANGE(DT_PROP(node, vhigh), TMC_RAMP_VHIGH_MIN, \
TMC_RAMP_VHIGH_MAX), "vhigh out of range"), ()); \
COND_CODE_1(DT_PROP_EXISTS(node, ihold), \
BUILD_ASSERT(IN_RANGE(DT_PROP(node, ihold), TMC_RAMP_IHOLD_IRUN_MIN, \
TMC_RAMP_IHOLD_IRUN_MAX), "ihold out of range"), ()); \
COND_CODE_1(DT_PROP_EXISTS(node, irun), \
BUILD_ASSERT(IN_RANGE(DT_PROP(node, irun), TMC_RAMP_IHOLD_IRUN_MIN, \
TMC_RAMP_IHOLD_IRUN_MAX), "irun out of range"), ()); \
COND_CODE_1(DT_PROP_EXISTS(node, iholddelay), \
BUILD_ASSERT(IN_RANGE(DT_PROP(node, iholddelay), TMC_RAMP_IHOLDDELAY_MIN, \
TMC_RAMP_IHOLDDELAY_MAX), "iholddelay out of range"), ());
#define DT_PROP(node_id, prop)
Get a devicetree property value.
Definition devicetree.h:745
#define COND_CODE_1(_flag, _if_1_code, _else_code)
Insert code depending on whether _flag expands to 1 or not.
Definition util_macro.h:195
#define IN_RANGE(val, min, max)
Checks if a value is within range.
Definition util.h:431
#define TMC_RAMP_TZEROWAIT_MAX
Definition stepper_trinamic.h:50
#define TMC_RAMP_A1_MAX
Definition stepper_trinamic.h:40
#define TMC_RAMP_VCOOLTHRS_MIN
Definition stepper_trinamic.h:53
#define TMC_RAMP_VHIGH_MAX
Definition stepper_trinamic.h:54
#define TMC_RAMP_VMAX_MIN
Definition stepper_trinamic.h:39
#define TMC_RAMP_TZEROWAIT_MIN
Definition stepper_trinamic.h:51
#define TMC_RAMP_AMAX_MIN
Definition stepper_trinamic.h:43
#define TMC_RAMP_IHOLDDELAY_MAX
Definition stepper_trinamic.h:58
#define TMC_RAMP_VMAX_MAX
Definition stepper_trinamic.h:38
#define TMC_RAMP_V1_MIN
Definition stepper_trinamic.h:37
#define TMC_RAMP_IHOLD_IRUN_MIN
Definition stepper_trinamic.h:57
#define TMC_RAMP_VSTART_MIN
Definition stepper_trinamic.h:35
#define TMC_RAMP_VSTOP_MAX
Definition stepper_trinamic.h:48
#define TMC_RAMP_IHOLDDELAY_MIN
Definition stepper_trinamic.h:59
#define TMC_RAMP_VHIGH_MIN
Definition stepper_trinamic.h:55
#define TMC_RAMP_DMAX_MAX
Definition stepper_trinamic.h:46
#define TMC_RAMP_V1_MAX
Definition stepper_trinamic.h:36
#define TMC_RAMP_D1_MAX
Definition stepper_trinamic.h:44
#define TMC_RAMP_D1_MIN
Definition stepper_trinamic.h:45
#define TMC_RAMP_VSTART_MAX
Trinamic stepper controller ramp generator data limits.
Definition stepper_trinamic.h:34
#define TMC_RAMP_VCOOLTHRS_MAX
Definition stepper_trinamic.h:52
#define TMC_RAMP_AMAX_MAX
Definition stepper_trinamic.h:42
#define TMC_RAMP_VSTOP_MIN
Definition stepper_trinamic.h:49
#define TMC_RAMP_A1_MIN
Definition stepper_trinamic.h:41
#define TMC_RAMP_IHOLD_IRUN_MAX
Definition stepper_trinamic.h:56
#define TMC_RAMP_DMAX_MIN
Definition stepper_trinamic.h:47

Check if Ramp DT data is within limits.

◆ TMC_RAMP_A1_MAX

#define TMC_RAMP_A1_MAX   GENMASK(15, 0)

◆ TMC_RAMP_A1_MIN

#define TMC_RAMP_A1_MIN   0

◆ TMC_RAMP_AMAX_MAX

#define TMC_RAMP_AMAX_MAX   GENMASK(15, 0)

◆ TMC_RAMP_AMAX_MIN

#define TMC_RAMP_AMAX_MIN   0

◆ TMC_RAMP_D1_MAX

#define TMC_RAMP_D1_MAX   GENMASK(15, 0)

◆ TMC_RAMP_D1_MIN

#define TMC_RAMP_D1_MIN   1

◆ TMC_RAMP_DMAX_MAX

#define TMC_RAMP_DMAX_MAX   GENMASK(15, 0)

◆ TMC_RAMP_DMAX_MIN

#define TMC_RAMP_DMAX_MIN   0

◆ TMC_RAMP_DT_SPEC_GET

#define TMC_RAMP_DT_SPEC_GET (   node)

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

Value:
{ \
.vstart = DT_PROP(node, vstart), \
.v1 = DT_PROP(node, v1), \
.vmax = DT_PROP(node, vmax), \
.a1 = DT_PROP(node, a1), \
.amax = DT_PROP(node, amax), \
.d1 = DT_PROP(node, d1), \
.dmax = DT_PROP(node, dmax), \
.vstop = DT_PROP(node, vstop), \
.tzerowait = DT_PROP(node, tzerowait), \
.vcoolthrs = DT_PROP(node, vcoolthrs), \
.vhigh = DT_PROP(node, vhigh), \
.iholdrun = (TMC5041_IRUN(DT_PROP(node, irun)) | \
TMC5041_IHOLD(DT_PROP(node, ihold)) | \
TMC5041_IHOLDDELAY(DT_PROP(node, iholddelay))), \
}

Get Trinamic Stepper Ramp Generator data from DT.

Parameters
nodeDT node identifier
Returns
struct tmc_ramp_generator_data

◆ TMC_RAMP_IHOLD_IRUN_MAX

#define TMC_RAMP_IHOLD_IRUN_MAX   GENMASK(4, 0)

◆ TMC_RAMP_IHOLD_IRUN_MIN

#define TMC_RAMP_IHOLD_IRUN_MIN   0

◆ TMC_RAMP_IHOLDDELAY_MAX

#define TMC_RAMP_IHOLDDELAY_MAX   GENMASK(3, 0)

◆ TMC_RAMP_IHOLDDELAY_MIN

#define TMC_RAMP_IHOLDDELAY_MIN   0

◆ TMC_RAMP_TZEROWAIT_MAX

#define TMC_RAMP_TZEROWAIT_MAX   (GENMASK(15, 0) - 512)

◆ TMC_RAMP_TZEROWAIT_MIN

#define TMC_RAMP_TZEROWAIT_MIN   0

◆ TMC_RAMP_V1_MAX

#define TMC_RAMP_V1_MAX   GENMASK(19, 0)

◆ TMC_RAMP_V1_MIN

#define TMC_RAMP_V1_MIN   0

◆ TMC_RAMP_VACTUAL_SHIFT

#define TMC_RAMP_VACTUAL_SHIFT   22

◆ TMC_RAMP_VCOOLTHRS_MAX

#define TMC_RAMP_VCOOLTHRS_MAX   GENMASK(22, 0)

◆ TMC_RAMP_VCOOLTHRS_MIN

#define TMC_RAMP_VCOOLTHRS_MIN   0

◆ TMC_RAMP_VHIGH_MAX

#define TMC_RAMP_VHIGH_MAX   GENMASK(22, 0)

◆ TMC_RAMP_VHIGH_MIN

#define TMC_RAMP_VHIGH_MIN   0

◆ TMC_RAMP_VMAX_MAX

#define TMC_RAMP_VMAX_MAX   (GENMASK(22, 0) - 512)

◆ TMC_RAMP_VMAX_MIN

#define TMC_RAMP_VMAX_MIN   0

◆ TMC_RAMP_VSTART_MAX

#define TMC_RAMP_VSTART_MAX   GENMASK(17, 0)

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

Trinamic stepper controller ramp generator data limits.

◆ TMC_RAMP_VSTART_MIN

#define TMC_RAMP_VSTART_MIN   0

◆ TMC_RAMP_VSTOP_MAX

#define TMC_RAMP_VSTOP_MAX   GENMASK(17, 0)

◆ TMC_RAMP_VSTOP_MIN

#define TMC_RAMP_VSTOP_MIN   1

Function Documentation

◆ tmc5041_stepper_set_ramp()

int tmc5041_stepper_set_ramp ( const struct device dev,
const struct tmc_ramp_generator_data ramp_data 
)

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

Configure Trinamic Stepper Ramp Generator.

Parameters
devPointer to the stepper motor controller instance
ramp_dataPointer to a struct containing the required ramp parameters
Return values
-EIOGeneral input / output error
-ENOSYSIf not implemented by device driver
0Success