diff options
| author | Jacob Rosenthal <[email protected]> | 2021-11-11 22:50:07 -0700 |
|---|---|---|
| committer | Jacob Rosenthal <[email protected]> | 2021-11-11 22:50:07 -0700 |
| commit | 7bee43df5a7eb6a62c926a079bcc2536452a0e6e (patch) | |
| tree | 9b1b4bcf3de57bef71ab2f69ae59eec62c747e92 | |
| parent | 937f49deadd603b871f16a05518dffdaa56f3ca4 (diff) | |
nrf: sequencepwm nitpicks for clarity
| -rw-r--r-- | embassy-nrf/src/pwm.rs | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/embassy-nrf/src/pwm.rs b/embassy-nrf/src/pwm.rs index 899bcf416..9a5659cc8 100644 --- a/embassy-nrf/src/pwm.rs +++ b/embassy-nrf/src/pwm.rs | |||
| @@ -396,7 +396,7 @@ impl<'d, T: Instance> SimplePwm<'d, T> { | |||
| 396 | 396 | ||
| 397 | r.seq0 | 397 | r.seq0 |
| 398 | .ptr | 398 | .ptr |
| 399 | .write(|w| unsafe { w.bits(&pwm.duty as *const _ as u32) }); | 399 | .write(|w| unsafe { w.bits((&pwm.duty).as_ptr() as u32) }); |
| 400 | 400 | ||
| 401 | r.seq0.cnt.write(|w| unsafe { w.bits(4) }); | 401 | r.seq0.cnt.write(|w| unsafe { w.bits(4) }); |
| 402 | r.seq0.refresh.write(|w| unsafe { w.bits(0) }); | 402 | r.seq0.refresh.write(|w| unsafe { w.bits(0) }); |
| @@ -447,17 +447,14 @@ impl<'d, T: Instance> SimplePwm<'d, T> { | |||
| 447 | 447 | ||
| 448 | self.duty[channel] = duty & 0x7FFF; | 448 | self.duty[channel] = duty & 0x7FFF; |
| 449 | 449 | ||
| 450 | r.seq0 | ||
| 451 | .ptr | ||
| 452 | .write(|w| unsafe { w.bits(&self.duty as *const _ as u32) }); | ||
| 453 | |||
| 454 | // defensive before seqstart | 450 | // defensive before seqstart |
| 455 | compiler_fence(Ordering::SeqCst); | 451 | compiler_fence(Ordering::SeqCst); |
| 456 | 452 | ||
| 457 | // tasks_seqstart() doesn't exist in all svds so write its bit instead | 453 | // tasks_seqstart() doesn't exist in all svds so write its bit instead |
| 458 | r.tasks_seqstart[0].write(|w| unsafe { w.bits(1) }); | 454 | r.tasks_seqstart[0].write(|w| unsafe { w.bits(1) }); |
| 459 | 455 | ||
| 460 | // defensive wait until waveform is loaded after seqstart | 456 | // defensive wait until waveform is loaded after seqstart so set_duty |
| 457 | // can't be called again while dma is still reading | ||
| 461 | while r.events_seqend[0].read().bits() == 0 {} | 458 | while r.events_seqend[0].read().bits() == 0 {} |
| 462 | r.events_seqend[0].write(|w| w); | 459 | r.events_seqend[0].write(|w| w); |
| 463 | } | 460 | } |
