Skip to content

Commit f9c2400

Browse files
committed
Disable sequence if set to None
1 parent c689eb6 commit f9c2400

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

nrf-hal-common/src/pwm.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -531,9 +531,6 @@ where
531531
B0: ReadBuffer<Word = u16> + 'static,
532532
B1: ReadBuffer<Word = u16> + 'static,
533533
{
534-
self.pwm.seq0.cnt.write(|w| unsafe { w.bits(0) });
535-
self.pwm.seq1.cnt.write(|w| unsafe { w.bits(0) });
536-
537534
if let Some(buf) = &seq0_buffer {
538535
let (ptr, len) = unsafe { buf.read_buffer() };
539536
if (ptr as usize) < SRAM_LOWER || (ptr as usize) > SRAM_UPPER {
@@ -548,13 +545,15 @@ where
548545
return Err((Error::BufferTooLong, self, seq0_buffer, seq1_buffer));
549546
}
550547
compiler_fence(Ordering::SeqCst);
551-
552548
self.pwm.seq0.ptr.write(|w| unsafe { w.bits(ptr as u32) });
553549
self.pwm.seq0.cnt.write(|w| unsafe { w.bits(len as u32) });
554550
if start {
555551
self.start_seq(Seq::Seq0);
556552
}
553+
} else {
554+
self.pwm.seq0.cnt.write(|w| unsafe { w.bits(0) });
557555
}
556+
558557
if let Some(buf) = &seq1_buffer {
559558
let (ptr, len) = unsafe { buf.read_buffer() };
560559
if (ptr as usize) < SRAM_LOWER || (ptr as usize) > SRAM_UPPER {
@@ -569,12 +568,13 @@ where
569568
return Err((Error::BufferTooLong, self, seq0_buffer, seq1_buffer));
570569
}
571570
compiler_fence(Ordering::SeqCst);
572-
573571
self.pwm.seq1.ptr.write(|w| unsafe { w.bits(ptr as u32) });
574572
self.pwm.seq1.cnt.write(|w| unsafe { w.bits(len as u32) });
575573
if start {
576574
self.start_seq(Seq::Seq1);
577575
}
576+
} else {
577+
self.pwm.seq1.cnt.write(|w| unsafe { w.bits(0) });
578578
}
579579

580580
Ok(PwmSeq {

0 commit comments

Comments
 (0)