aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-nrf/src/pwm.rs18
1 files changed, 8 insertions, 10 deletions
diff --git a/embassy-nrf/src/pwm.rs b/embassy-nrf/src/pwm.rs
index 9672e6f22..64a25f238 100644
--- a/embassy-nrf/src/pwm.rs
+++ b/embassy-nrf/src/pwm.rs
@@ -236,18 +236,19 @@ impl<'d, T: Instance> Pwm<'d, T> {
236 .write(|w| unsafe { w.bits(config.enddelay) }); 236 .write(|w| unsafe { w.bits(config.enddelay) });
237 237
238 match config.additional_loops { 238 match config.additional_loops {
239 // just the one time, no loop count
239 LoopMode::Additional(0) => { 240 LoopMode::Additional(0) => {
240 r.loop_.write(|w| w.cnt().disabled()); 241 r.loop_.write(|w| w.cnt().disabled());
242 // tasks_seqstart doesnt exist in all svds so write its bit instead
241 r.tasks_seqstart[0].write(|w| unsafe { w.bits(0x01) }); 243 r.tasks_seqstart[0].write(|w| unsafe { w.bits(0x01) });
242 } 244 }
245 // loop count is how many times to play BOTH sequences
246 // the one time + 1 = 2 total, play the sequence once starting from seq0
247 // the one time + 2 = 3 total, playing the sequence twice would be too much, but we can start on seq1 to subtract one
248 // the one time + 3 = 4 total, play the sequence twice starting from seq0
243 LoopMode::Additional(n) => { 249 LoopMode::Additional(n) => {
244 let times = (n / 2) + 1; 250 let times = (n / 2) + 1;
245
246 r.loop_.write(|w| unsafe { w.cnt().bits(times) }); 251 r.loop_.write(|w| unsafe { w.cnt().bits(times) });
247 r.shorts.write(|w| {
248 w.loopsdone_seqstart1().enabled();
249 w.loopsdone_stop().enabled()
250 });
251 252
252 if n & 1 == 1 { 253 if n & 1 == 1 {
253 // tasks_seqstart doesnt exist in all svds so write its bit instead 254 // tasks_seqstart doesnt exist in all svds so write its bit instead
@@ -257,13 +258,10 @@ impl<'d, T: Instance> Pwm<'d, T> {
257 r.tasks_seqstart[1].write(|w| unsafe { w.bits(0x01) }); 258 r.tasks_seqstart[1].write(|w| unsafe { w.bits(0x01) });
258 } 259 }
259 } 260 }
260
261 LoopMode::Infinite => { 261 LoopMode::Infinite => {
262 r.loop_.write(|w| unsafe { w.cnt().bits(0x1) }); 262 r.loop_.write(|w| unsafe { w.cnt().bits(0x1) });
263 r.shorts.write(|w| { 263 r.shorts.write(|w| w.loopsdone_seqstart1().enabled());
264 w.loopsdone_seqstart1().enabled(); 264 // tasks_seqstart doesnt exist in all svds so write its bit instead
265 w.loopsdone_seqstart0().disabled()
266 });
267 r.tasks_seqstart[1].write(|w| unsafe { w.bits(0x01) }); 265 r.tasks_seqstart[1].write(|w| unsafe { w.bits(0x01) });
268 } 266 }
269 } 267 }