fix additional to remove stuck light at end
This commit is contained in:
parent
d98a1707b9
commit
72fa1c8482
@ -236,18 +236,19 @@ impl<'d, T: Instance> Pwm<'d, T> {
|
|||||||
.write(|w| unsafe { w.bits(config.enddelay) });
|
.write(|w| unsafe { w.bits(config.enddelay) });
|
||||||
|
|
||||||
match config.additional_loops {
|
match config.additional_loops {
|
||||||
|
// just the one time, no loop count
|
||||||
LoopMode::Additional(0) => {
|
LoopMode::Additional(0) => {
|
||||||
r.loop_.write(|w| w.cnt().disabled());
|
r.loop_.write(|w| w.cnt().disabled());
|
||||||
|
// tasks_seqstart doesnt exist in all svds so write its bit instead
|
||||||
r.tasks_seqstart[0].write(|w| unsafe { w.bits(0x01) });
|
r.tasks_seqstart[0].write(|w| unsafe { w.bits(0x01) });
|
||||||
}
|
}
|
||||||
|
// loop count is how many times to play BOTH sequences
|
||||||
|
// the one time + 1 = 2 total, play the sequence once starting from seq0
|
||||||
|
// the one time + 2 = 3 total, playing the sequence twice would be too much, but we can start on seq1 to subtract one
|
||||||
|
// the one time + 3 = 4 total, play the sequence twice starting from seq0
|
||||||
LoopMode::Additional(n) => {
|
LoopMode::Additional(n) => {
|
||||||
let times = (n / 2) + 1;
|
let times = (n / 2) + 1;
|
||||||
|
|
||||||
r.loop_.write(|w| unsafe { w.cnt().bits(times) });
|
r.loop_.write(|w| unsafe { w.cnt().bits(times) });
|
||||||
r.shorts.write(|w| {
|
|
||||||
w.loopsdone_seqstart1().enabled();
|
|
||||||
w.loopsdone_stop().enabled()
|
|
||||||
});
|
|
||||||
|
|
||||||
if n & 1 == 1 {
|
if n & 1 == 1 {
|
||||||
// tasks_seqstart doesnt exist in all svds so write its bit instead
|
// tasks_seqstart doesnt exist in all svds so write its bit instead
|
||||||
@ -257,13 +258,10 @@ impl<'d, T: Instance> Pwm<'d, T> {
|
|||||||
r.tasks_seqstart[1].write(|w| unsafe { w.bits(0x01) });
|
r.tasks_seqstart[1].write(|w| unsafe { w.bits(0x01) });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LoopMode::Infinite => {
|
LoopMode::Infinite => {
|
||||||
r.loop_.write(|w| unsafe { w.cnt().bits(0x1) });
|
r.loop_.write(|w| unsafe { w.cnt().bits(0x1) });
|
||||||
r.shorts.write(|w| {
|
r.shorts.write(|w| w.loopsdone_seqstart1().enabled());
|
||||||
w.loopsdone_seqstart1().enabled();
|
// tasks_seqstart doesnt exist in all svds so write its bit instead
|
||||||
w.loopsdone_seqstart0().disabled()
|
|
||||||
});
|
|
||||||
r.tasks_seqstart[1].write(|w| unsafe { w.bits(0x01) });
|
r.tasks_seqstart[1].write(|w| unsafe { w.bits(0x01) });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user