Skip to content

Struct SYN_DCMotor

ClassList > SYN_DCMotor

DC motor instance — pins, speed, ramp state.

  • #include <syn_dc_motor.h>

Public Attributes

Type Name
void * duty_ctx
int32_t duty_max
bool invert
uint32_t last_tick
uint8_t mode
SYN_GPIO_Pin pin_a
SYN_GPIO_Pin pin_b
SYN_Ramp ramp
int32_t ramp_rate
void(* set_duty
int32_t speed
int32_t target

Public Attributes Documentation

variable duty_ctx

void* SYN_DCMotor::duty_ctx;

Context for set_duty


variable duty_max

int32_t SYN_DCMotor::duty_max;

Maximum duty cycle value. Output range is [-duty_max, +duty_max]. Set to match your PWM timer resolution (e.g., 255 for 8-bit, 1000 for 0.1%, 4095 for 12-bit, 65535 for 16-bit). Default: SYN_DC_MOTOR_DUTY_MAX_DEFAULT (1000).


variable invert

bool SYN_DCMotor::invert;

Invert direction


variable last_tick

uint32_t SYN_DCMotor::last_tick;

Last ramp update tick


variable mode

uint8_t SYN_DCMotor::mode;

SYN_DCMotorMode


variable pin_a

SYN_GPIO_Pin SYN_DCMotor::pin_a;

PWM pin (or IN_A for dual mode)


variable pin_b

SYN_GPIO_Pin SYN_DCMotor::pin_b;

DIR pin (or IN_B for dual mode)


variable ramp

SYN_Ramp SYN_DCMotor::ramp;

Internal velocity ramp generator


variable ramp_rate

int32_t SYN_DCMotor::ramp_rate;

Rate of speed change (per ms, Q8)


variable set_duty

void(* SYN_DCMotor::set_duty) (SYN_GPIO_Pin pin, uint16_t duty, void *ctx);

Duty output callback — user provides this to set actual PWM duty.

Parameters:

  • pin GPIO pin to set duty on.
  • duty Duty cycle value in range [0, duty_max].
  • ctx User context.

variable speed

int32_t SYN_DCMotor::speed;

Current speed (-duty_max to +duty_max)


variable target

int32_t SYN_DCMotor::target;

Target speed for ramping



The documentation for this class was generated from the following file src/syntropic/motor/syn_dc_motor.h