@@ -178,9 +178,9 @@ impl<'d, T: AdvancedInstance4Channel> ComplementaryPwm<'d, T> {
178178 /// This value depends on the configured frequency and the timer's clock rate from RCC.
179179 pub fn get_max_duty ( & self ) -> u16 {
180180 if self . inner . get_counting_mode ( ) . is_center_aligned ( ) {
181- self . inner . get_max_compare_value ( ) as u16
181+ unwrap ! ( self . inner. get_max_compare_value( ) . try_into ( ) )
182182 } else {
183- self . inner . get_max_compare_value ( ) as u16 + 1
183+ unwrap ! ( self . inner. get_max_compare_value( ) . try_into ( ) ) + 1
184184 }
185185 }
186186
@@ -189,7 +189,7 @@ impl<'d, T: AdvancedInstance4Channel> ComplementaryPwm<'d, T> {
189189 /// The value ranges from 0 for 0% duty, to [`get_max_duty`](Self::get_max_duty) for 100% duty, both included.
190190 pub fn set_duty ( & mut self , channel : Channel , duty : u16 ) {
191191 assert ! ( duty <= self . get_max_duty( ) ) ;
192- self . inner . set_compare_value ( channel, duty as _ )
192+ self . inner . set_compare_value ( channel, duty. into ( ) )
193193 }
194194
195195 /// Set the output polarity for a given channel.
@@ -220,7 +220,7 @@ impl<'d, T: AdvancedInstance4Channel> ComplementaryPwm<'d, T> {
220220 ///
221221 /// Note:
222222 /// you will need to provide corresponding TIMx_UP DMA channel to use this method.
223- pub async fn waveform_up ( & mut self , dma : Peri < ' _ , impl super :: UpDma < T > > , channel : Channel , duty : & [ u16 ] ) {
223+ pub async fn waveform_up ( & mut self , dma : Peri < ' _ , impl super :: UpDma < T > > , channel : Channel , duty : & [ T :: Word ] ) {
224224 self . inner . enable_channel ( channel, true ) ;
225225 self . inner . enable_update_dma ( true ) ;
226226 self . inner . setup_update_dma ( dma, channel, duty) . await ;
@@ -261,7 +261,7 @@ impl<'d, T: AdvancedInstance4Channel> ComplementaryPwm<'d, T> {
261261 dma : Peri < ' _ , impl super :: UpDma < T > > ,
262262 starting_channel : Channel ,
263263 ending_channel : Channel ,
264- duty : & [ u16 ] ,
264+ duty : & [ T :: Word ] ,
265265 ) {
266266 self . inner . enable_update_dma ( true ) ;
267267 self . inner
@@ -291,20 +291,20 @@ impl<'d, T: AdvancedInstance4Channel> embedded_hal_02::Pwm for ComplementaryPwm<
291291 }
292292
293293 fn get_duty ( & self , channel : Self :: Channel ) -> Self :: Duty {
294- self . inner . get_compare_value ( channel) as u16
294+ unwrap ! ( self . inner. get_compare_value( channel) . try_into ( ) )
295295 }
296296
297297 fn get_max_duty ( & self ) -> Self :: Duty {
298298 if self . inner . get_counting_mode ( ) . is_center_aligned ( ) {
299- self . inner . get_max_compare_value ( ) as u16
299+ unwrap ! ( self . inner. get_max_compare_value( ) . try_into ( ) )
300300 } else {
301- self . inner . get_max_compare_value ( ) as u16 + 1
301+ unwrap ! ( self . inner. get_max_compare_value( ) . try_into ( ) ) + 1
302302 }
303303 }
304304
305305 fn set_duty ( & mut self , channel : Self :: Channel , duty : Self :: Duty ) {
306306 assert ! ( duty <= self . get_max_duty( ) ) ;
307- self . inner . set_compare_value ( channel, duty as u32 )
307+ self . inner . set_compare_value ( channel, unwrap ! ( duty. try_into ( ) ) )
308308 }
309309
310310 fn set_period < P > ( & mut self , period : P )
0 commit comments