File syn_stepper.c¶
FileList > motor > syn_stepper.c
Go to the source code of this file
Stepper motor driver implementation.
#include "../util/syn_assert.h"#include "syn_stepper.h"#include <string.h>
Public Functions¶
| Type | Name |
|---|---|
| void | syn_stepper_enable (const SYN_Stepper * s, bool enable) Enable or disable the motor driver. |
| void | syn_stepper_init (SYN_Stepper * s, SYN_GPIO_Pin step_pin, SYN_GPIO_Pin dir_pin) Initialize stepper motor driver. |
| void | syn_stepper_move (SYN_Stepper * s, int32_t steps) Start a relative move. |
| void | syn_stepper_move_to (SYN_Stepper * s, int32_t position) Start a move to an absolute position. |
| SYN_MotorOutput | syn_stepper_output (SYN_Stepper * stepper) Create a SYN_MotorOutput interface for this stepper. |
| void | syn_stepper_set_enable_pin (SYN_Stepper * s, SYN_GPIO_Pin pin, bool active_low) Set optional enable pin. |
| void | syn_stepper_set_speed (SYN_Stepper * s, uint32_t max_sps, uint32_t accel_sps2) Set maximum speed and acceleration. |
| void | syn_stepper_stop (SYN_Stepper * s) Emergency stop — immediately halt with no deceleration. |
| void | syn_stepper_tick (SYN_Stepper * s) Advance the stepper state machine by one tick. |
Public Static Functions¶
| Type | Name |
|---|---|
| void | set_direction (const SYN_Stepper * s, bool forward) Set stepper direction pin. |
| void | stepper_output_brake (void * ctx) Brake adapter for SYN_MotorOutput . |
| void | stepper_output_coast (void * ctx) Coast adapter for SYN_MotorOutput . |
| void | stepper_output_set (void * ctx, int32_t output) Set output adapter for SYN_MotorOutput (ticks the stepper). |
Public Functions Documentation¶
function syn_stepper_enable¶
Enable or disable the motor driver.
Parameters:
sStepper instance.enabletrue to enable, false to disable.
function syn_stepper_init¶
Initialize stepper motor driver.
Parameters:
sStepper instance.step_pinStep pulse GPIO.dir_pinDirection GPIO.
function syn_stepper_move¶
Start a relative move.
Parameters:
sStepper handle.stepsNumber of steps (positive = forward, negative = reverse).
function syn_stepper_move_to¶
Start a move to an absolute position.
Parameters:
sStepper.positionTarget absolute position in steps.
function syn_stepper_output¶
Create a SYN_MotorOutput interface for this stepper.
The set_output callback calls syn_stepper_tick(), coast/brake both call syn_stepper_stop(). The motor controller's output value is not used directly — stepper motion is driven by the stepper's own move/move_to commands.
Parameters:
stepperStepper instance (must outlive the returned output).
Returns:
Motor output interface.
function syn_stepper_set_enable_pin¶
Set optional enable pin.
Parameters:
sStepper instance.pinEnable signal GPIO pin.active_lowTrue if enabling requires driving pin LOW.
function syn_stepper_set_speed¶
Set maximum speed and acceleration.
Parameters:
sStepper.max_spsMaximum speed in steps per second.accel_sps2Acceleration in steps per second².
function syn_stepper_stop¶
Emergency stop — immediately halt with no deceleration.
Parameters:
sStepper instance.
function syn_stepper_tick¶
Advance the stepper state machine by one tick.
Call from a timer ISR or high-frequency loop. The tick rate should be at least 2× the maximum step rate for proper pulse generation.
Parameters:
sStepper instance.
Public Static Functions Documentation¶
function set_direction¶
Set stepper direction pin.
Parameters:
sStepper instance.forwardtrue for forward, false for reverse.
function stepper_output_brake¶
Brake adapter for SYN_MotorOutput .
Parameters:
ctxStepper instance (SYN_Stepper*).
function stepper_output_coast¶
Coast adapter for SYN_MotorOutput .
Parameters:
ctxStepper instance (SYN_Stepper*).
function stepper_output_set¶
Set output adapter for SYN_MotorOutput (ticks the stepper).
Parameters:
ctxStepper instance (SYN_Stepper*).outputUnused — stepper motion is driven by its own commands.
The documentation for this class was generated from the following file src/syntropic/motor/syn_stepper.c