Skip to content

Commit

Permalink
More explanatory comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Grazfather committed Jan 25, 2025
1 parent d58b7e6 commit afad2b6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions drivers/stepper/stepper.zig
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ pub fn Stepper(comptime Driver: type) type {
pub fn enable(self: *Self) !void {
if (self.enable_pin) |pin| {
try pin.write(self.enable_active_state);
self.clock.sleep_us(Driver.WAKEUP_TIME);
// We only need to wait if we are using the enable pin to
// enter/leave nSLEEP. If we are instead setting nEN, we can
// skip this.
if (self.enable_active_state == .high)
self.clock.sleep_us(Driver.WAKEUP_TIME);
}
}

Expand Down Expand Up @@ -334,8 +338,8 @@ pub fn Stepper(comptime Driver: type) type {
}

// Configure what value to write to the enable pin to enable the
// driver. This is LOW when this pin is hooked up to EN(bar), but HIGH
// when hooked up to SLEEP(bar)
// driver. This is LOW when this pin is hooked up to nENABLE, but HIGH
// when hooked up to nSLEEP.
pub fn set_enable_active_state(self: *Self, state: mdf.base.Digital_IO.State) void {
self.enable_active_state = state;
}
Expand Down

0 comments on commit afad2b6

Please sign in to comment.