How violet10b/hwstepgen works
HWStepGen is an ESP32 stepper-motor speed-control library: applications configure motors, command speed or direction, optionally ramp speed, and the LEDC peripheral generates STEP pulses independently of the CPU. It provides single-motor control, coordinated multi-motor operations, frequency/timer checks, and hardware-capability limits. The graph follows calls visible in sampled source; README-documented behavior whose internal wiring was not sampled is represented only where its owning module is clear.
Main entry points: Stepper.cpp Stepper control · LedcBackend.cpp LEDC backend · Ramp.cpp Speed ramp · StepperBank.cpp Stepper bank
Components 15
Motor API
- Stepper control
src/hwsg/Stepper.cpp - Config and errors
src/hwsg/Types.cpp
Motion Coordination
- Speed ramp
src/hwsg/Ramp.cpp - Stepper bank
src/hwsg/StepperBank.cpp
Pulse Hardware
- Backend selector
src/hwsg/detail/Backend.h - LEDC backend
src/hwsg/detail/LedcBackend.cpp - Channel allocator
src/hwsg/detail/LedcBackend.cpp - LEDC compatibility
src/hwsg/detail/Ledc.h
ESP32 Platform
- SoC capabilities
src/hwsg/detail/SocCaps.h
Other components
- Arduino application
- Arduino ESP32 core
- LEDC peripheral
- ESP32 GPIO
- Step-dir driver
- Stepper motor
Connections 17
- Arduino application → Stepper control: commands
- Arduino application → Speed ramp: updates
- Arduino application → Stepper bank: group commands
- Speed ramp → Stepper control: sets speed
- Stepper bank → Stepper control: dispatches
- Stepper control → Backend selector: controls pulses
- Stepper control → ESP32 GPIO: sets DIR/ENABLE
- Backend selector → LEDC backend: selects default
- LEDC backend → Channel allocator: reserves timer
- LEDC backend → LEDC compatibility: configures output
- LEDC backend → SoC capabilities: uses capabilities
- LEDC compatibility → Arduino ESP32 core: calls LEDC API
- Arduino ESP32 core → LEDC peripheral: configures
- Stepper control → SoC capabilities: checks pins/ranges
- LEDC peripheral → Step-dir driver: emits STEP pulses
- ESP32 GPIO → Step-dir driver: drives DIR/ENABLE
- Step-dir driver → Stepper motor: drives coils