aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Rosenthal <[email protected]>2021-11-11 19:49:41 -0700
committerJacob Rosenthal <[email protected]>2021-11-11 19:49:41 -0700
commitfe83daf45ff2a7e8b76425b53903d75548dc458f (patch)
tree388349212753f8917c6457676300befce82606a9
parentec66fcd01a9dd4e7a9d7b2e6c7dfcf92f9c9901d (diff)
remove const generic
-rw-r--r--embassy-nrf/src/pwm.rs16
1 files changed, 9 insertions, 7 deletions
diff --git a/embassy-nrf/src/pwm.rs b/embassy-nrf/src/pwm.rs
index 642620673..a850aac2d 100644
--- a/embassy-nrf/src/pwm.rs
+++ b/embassy-nrf/src/pwm.rs
@@ -24,7 +24,7 @@ pub struct SimplePwm<'d, T: Instance> {
24 24
25/// SequencePwm allows you to offload the updating of a sequence of duty cycles 25/// SequencePwm allows you to offload the updating of a sequence of duty cycles
26/// to up to four channels, as well as repeat that sequence n times. 26/// to up to four channels, as well as repeat that sequence n times.
27pub struct SequencePwm<'d, T: Instance, const N: usize> { 27pub struct SequencePwm<'d, T: Instance> {
28 phantom: PhantomData<&'d mut T>, 28 phantom: PhantomData<&'d mut T>,
29 ch0: Option<AnyPin>, 29 ch0: Option<AnyPin>,
30 ch1: Option<AnyPin>, 30 ch1: Option<AnyPin>,
@@ -44,7 +44,7 @@ pub enum Error {
44 DMABufferNotInDataMemory, 44 DMABufferNotInDataMemory,
45} 45}
46 46
47impl<'d, T: Instance, const N: usize> SequencePwm<'d, T, N> { 47impl<'d, T: Instance> SequencePwm<'d, T> {
48 /// Creates the interface to a `SequencePwm`. 48 /// Creates the interface to a `SequencePwm`.
49 /// 49 ///
50 /// Must be started by calling `start` 50 /// Must be started by calling `start`
@@ -62,11 +62,11 @@ impl<'d, T: Instance, const N: usize> SequencePwm<'d, T, N> {
62 ch2: impl Unborrow<Target = impl GpioOptionalPin> + 'd, 62 ch2: impl Unborrow<Target = impl GpioOptionalPin> + 'd,
63 ch3: impl Unborrow<Target = impl GpioOptionalPin> + 'd, 63 ch3: impl Unborrow<Target = impl GpioOptionalPin> + 'd,
64 config: SequenceConfig, 64 config: SequenceConfig,
65 sequence: [u16; N], 65 sequence: &mut [u16],
66 ) -> Result<Self, Error> { 66 ) -> Result<Self, Error> {
67 slice_in_ram_or(&sequence, Error::DMABufferNotInDataMemory)?; 67 slice_in_ram_or(sequence, Error::DMABufferNotInDataMemory)?;
68 68
69 if N > 32767 { 69 if sequence.len() > 32767 {
70 return Err(Error::SequenceTooLong); 70 return Err(Error::SequenceTooLong);
71 } 71 }
72 72
@@ -108,7 +108,9 @@ impl<'d, T: Instance, const N: usize> SequencePwm<'d, T, N> {
108 r.seq0 108 r.seq0
109 .ptr 109 .ptr
110 .write(|w| unsafe { w.bits(sequence.as_ptr() as u32) }); 110 .write(|w| unsafe { w.bits(sequence.as_ptr() as u32) });
111 r.seq0.cnt.write(|w| unsafe { w.bits(N as u32) }); 111 r.seq0
112 .cnt
113 .write(|w| unsafe { w.bits(sequence.len() as u32) });
112 r.seq0.refresh.write(|w| unsafe { w.bits(config.refresh) }); 114 r.seq0.refresh.write(|w| unsafe { w.bits(config.refresh) });
113 r.seq0 115 r.seq0
114 .enddelay 116 .enddelay
@@ -222,7 +224,7 @@ impl<'d, T: Instance, const N: usize> SequencePwm<'d, T, N> {
222 } 224 }
223} 225}
224 226
225impl<'a, T: Instance, const N: usize> Drop for SequencePwm<'a, T, N> { 227impl<'a, T: Instance> Drop for SequencePwm<'a, T> {
226 fn drop(&mut self) { 228 fn drop(&mut self) {
227 let r = T::regs(); 229 let r = T::regs();
228 230