diff options
Diffstat (limited to 'embassy-stm32/src/timer/ringbuffered.rs')
| -rw-r--r-- | embassy-stm32/src/timer/ringbuffered.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/embassy-stm32/src/timer/ringbuffered.rs b/embassy-stm32/src/timer/ringbuffered.rs index e8f97bf59..f5a4328d1 100644 --- a/embassy-stm32/src/timer/ringbuffered.rs +++ b/embassy-stm32/src/timer/ringbuffered.rs | |||
| @@ -25,7 +25,7 @@ use crate::dma::ringbuffer::Error; | |||
| 25 | /// ``` | 25 | /// ``` |
| 26 | pub struct RingBufferedPwmChannel<'d, T: GeneralInstance4Channel> { | 26 | pub struct RingBufferedPwmChannel<'d, T: GeneralInstance4Channel> { |
| 27 | timer: ManuallyDrop<Timer<'d, T>>, | 27 | timer: ManuallyDrop<Timer<'d, T>>, |
| 28 | ring_buf: WritableRingBuffer<'d, u16>, | 28 | ring_buf: WritableRingBuffer<'d, T::Word>, |
| 29 | channel: Channel, | 29 | channel: Channel, |
| 30 | } | 30 | } |
| 31 | 31 | ||
| @@ -33,7 +33,7 @@ impl<'d, T: GeneralInstance4Channel> RingBufferedPwmChannel<'d, T> { | |||
| 33 | pub(crate) fn new( | 33 | pub(crate) fn new( |
| 34 | timer: ManuallyDrop<Timer<'d, T>>, | 34 | timer: ManuallyDrop<Timer<'d, T>>, |
| 35 | channel: Channel, | 35 | channel: Channel, |
| 36 | ring_buf: WritableRingBuffer<'d, u16>, | 36 | ring_buf: WritableRingBuffer<'d, T::Word>, |
| 37 | ) -> Self { | 37 | ) -> Self { |
| 38 | Self { | 38 | Self { |
| 39 | timer, | 39 | timer, |
| @@ -55,18 +55,18 @@ impl<'d, T: GeneralInstance4Channel> RingBufferedPwmChannel<'d, T> { | |||
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | /// Write elements directly to the raw buffer. This can be used to fill the buffer before starting the DMA transfer. | 57 | /// Write elements directly to the raw buffer. This can be used to fill the buffer before starting the DMA transfer. |
| 58 | pub fn write_immediate(&mut self, buf: &[u16]) -> Result<(usize, usize), Error> { | 58 | pub fn write_immediate(&mut self, buf: &[T::Word]) -> Result<(usize, usize), Error> { |
| 59 | self.ring_buf.write_immediate(buf) | 59 | self.ring_buf.write_immediate(buf) |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | /// Write elements from the ring buffer | 62 | /// Write elements from the ring buffer |
| 63 | /// Return a tuple of the length written and the length remaining in the buffer | 63 | /// Return a tuple of the length written and the length remaining in the buffer |
| 64 | pub fn write(&mut self, buf: &[u16]) -> Result<(usize, usize), Error> { | 64 | pub fn write(&mut self, buf: &[T::Word]) -> Result<(usize, usize), Error> { |
| 65 | self.ring_buf.write(buf) | 65 | self.ring_buf.write(buf) |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | /// Write an exact number of elements to the ringbuffer. | 68 | /// Write an exact number of elements to the ringbuffer. |
| 69 | pub async fn write_exact(&mut self, buffer: &[u16]) -> Result<usize, Error> { | 69 | pub async fn write_exact(&mut self, buffer: &[T::Word]) -> Result<usize, Error> { |
| 70 | self.ring_buf.write_exact(buffer).await | 70 | self.ring_buf.write_exact(buffer).await |
| 71 | } | 71 | } |
| 72 | 72 | ||
| @@ -140,7 +140,7 @@ impl<'d, T: GeneralInstance4Channel> RingBufferedPwmChannel<'d, T> { | |||
| 140 | /// | 140 | /// |
| 141 | /// This value depends on the configured frequency and the timer's clock rate from RCC. | 141 | /// This value depends on the configured frequency and the timer's clock rate from RCC. |
| 142 | pub fn max_duty_cycle(&self) -> u16 { | 142 | pub fn max_duty_cycle(&self) -> u16 { |
| 143 | let max = self.timer.get_max_compare_value(); | 143 | let max: u32 = self.timer.get_max_compare_value().into(); |
| 144 | assert!(max < u16::MAX as u32); | 144 | assert!(max < u16::MAX as u32); |
| 145 | max as u16 + 1 | 145 | max as u16 + 1 |
| 146 | } | 146 | } |
