Skip to content

Commit

Permalink
src: lib: pwm: Add pwm enable and disable methods
Browse files Browse the repository at this point in the history
  • Loading branch information
RaulTrombin authored and joaoantoniocardoso committed Jun 27, 2023
1 parent 4688ebe commit fb54386
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ impl Navigator {
self.pwm.reset_internal_driver_state();
self.pwm.use_external_clock().unwrap();
self.pwm.set_prescale(100).unwrap();
self.pwm.enable().unwrap();

self.bmp.zero().unwrap();

Expand All @@ -222,6 +221,16 @@ impl Navigator {
.expect("Error : Error on magnetometer during self-test")
}

pub fn pwm_enable(&mut self) {
self.pwm.enable().unwrap();
self.pwm.oe_pin.set_direction(Direction::Low).unwrap();
}

pub fn pwm_disable(&mut self) {
self.pwm.disable().unwrap();
self.pwm.oe_pin.set_direction(Direction::High).unwrap();
}

pub fn set_pwm_channel_value(&mut self, channel: pwm_Channel, value: u16) {
self.pwm.set_channel_on(channel, 0).unwrap();
self.pwm.set_channel_off(channel, value).unwrap();
Expand Down

0 comments on commit fb54386

Please sign in to comment.