aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Rosenthal <[email protected]>2021-11-01 13:00:50 -0700
committerJacob Rosenthal <[email protected]>2021-11-01 13:08:55 -0700
commitf2cfbe42629c74fd53f709ad7187d00b21d7030a (patch)
treef67029a0bf7513d3dbcb9bd997525db9f9ea38f9
parent5285179218a0d5137dc6c1c16f2d01617c310a0a (diff)
align pwm.set_duty with embedded hal to not be one shot
-rw-r--r--embassy-nrf/src/pwm.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/embassy-nrf/src/pwm.rs b/embassy-nrf/src/pwm.rs
index 31e8a3b6d..3594e6afd 100644
--- a/embassy-nrf/src/pwm.rs
+++ b/embassy-nrf/src/pwm.rs
@@ -282,8 +282,15 @@ impl<'d, T: Instance> Pwm<'d, T> {
282 let s = T::state(); 282 let s = T::state();
283 unsafe { (*s.duty.get())[channel] = duty & 0x7FFF }; 283 unsafe { (*s.duty.get())[channel] = duty & 0x7FFF };
284 284
285 // todo justify? should i fence elsehwere we task start? or
285 compiler_fence(Ordering::SeqCst); 286 compiler_fence(Ordering::SeqCst);
286 T::regs().tasks_seqstart[0].write(|w| unsafe { w.bits(1) }); 287
288 // play duty cycle infinitely
289 let r = T::regs();
290 r.loop_.write(|w| unsafe { w.cnt().bits(0x1) });
291 r.shorts.write(|w| w.loopsdone_seqstart0().enabled());
292 // tasks_seqstart doesnt exist in all svds so write its bit instead
293 r.tasks_seqstart[0].write(|w| unsafe { w.bits(1) });
287 } 294 }
288 295
289 /// Sets the PWM clock prescaler. 296 /// Sets the PWM clock prescaler.