Skip to content

Commit 357f4d6

Browse files
authored
Merge pull request #668 from jlpettersson/enable_multiple_pwm_slices_atomically
Add function to enable multiple PWM slices at the same time
2 parents 8a68410 + a7f51b7 commit 357f4d6

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

rp2040-hal/src/pwm/mod.rs

+10-11
Original file line numberDiff line numberDiff line change
@@ -554,17 +554,16 @@ impl Slices {
554554
self._pwm
555555
}
556556

557-
// /// Enable multiple slices at the same time to make their counters sync up.
558-
// ///
559-
// /// You still need to call `slice` to get an actual slice
560-
// pub fn enable_simultaneous<S: SliceId>(&mut self, bits: u8) {
561-
// // Enable all slices at the same time
562-
// unsafe {
563-
// &(*pac::PWM::ptr())
564-
// .en
565-
// .modify(|r, w| w.bits(((r.bits() as u8) | bits) as u32));
566-
// }
567-
// }
557+
/// Enable multiple slices at the same time to make their counters sync up.
558+
///
559+
/// You still need to call `slice` to get an actual slice
560+
pub fn enable_simultaneous(&mut self, bits: u8) {
561+
// Enable multiple slices at the same time
562+
unsafe {
563+
let reg = self._pwm.en.as_ptr();
564+
write_bitmask_set(reg, bits as u32);
565+
}
566+
}
568567

569568
// /// Get pwm slice based on gpio pin
570569
// pub fn borrow_mut_from_pin<

0 commit comments

Comments
 (0)