@@ -147,29 +147,15 @@ impl<USART: Instance> SerialExt for USART {
147147 config : impl Into < Config > ,
148148 clocks : & Clocks ,
149149 ) -> Tx < Self > {
150- Serial :: _new (
151- self ,
152- ( Some ( tx_pin) , None :: < USART :: Rx < Floating > > ) ,
153- config,
154- clocks,
155- )
156- . split ( )
157- . 0
150+ Serial :: tx ( self , tx_pin, config, clocks)
158151 }
159152 fn rx < PULL : UpMode > (
160153 self ,
161154 rx_pin : impl RInto < Self :: Rx < PULL > , 0 > ,
162155 config : impl Into < Config > ,
163156 clocks : & Clocks ,
164157 ) -> Rx < Self > {
165- Serial :: _new (
166- self ,
167- ( None :: < USART :: Tx < PushPull > > , Some ( rx_pin) ) ,
168- config,
169- clocks,
170- )
171- . split ( )
172- . 1
158+ Serial :: rx ( self , rx_pin, config, clocks)
173159 }
174160}
175161
@@ -388,38 +374,24 @@ impl<USART: Instance, const R: u8> Rmp<USART, R> {
388374}
389375
390376impl < USART : Instance , Otype > Serial < USART , Otype , Floating > {
391- pub fn tx (
392- usart : USART ,
393- tx_pin : impl RInto < USART :: Tx < Otype > , 0 > ,
377+ pub fn tx < const R : u8 > (
378+ usart : impl Into < Rmp < USART , R > > ,
379+ tx_pin : impl RInto < USART :: Tx < Otype > , R > ,
394380 config : impl Into < Config > ,
395381 clocks : & Clocks ,
396382 ) -> Tx < USART > {
397- Self :: _new (
398- usart,
399- ( Some ( tx_pin) , None :: < USART :: Rx < Floating > > ) ,
400- config,
401- clocks,
402- )
403- . split ( )
404- . 0
383+ usart. into ( ) . tx ( tx_pin, config, clocks)
405384 }
406385}
407386
408387impl < USART : Instance , PULL : UpMode > Serial < USART , PushPull , PULL > {
409- pub fn rx (
410- usart : USART ,
411- rx_pin : impl RInto < USART :: Rx < PULL > , 0 > ,
388+ pub fn rx < const R : u8 > (
389+ usart : impl Into < Rmp < USART , R > > ,
390+ rx_pin : impl RInto < USART :: Rx < PULL > , R > ,
412391 config : impl Into < Config > ,
413392 clocks : & Clocks ,
414393 ) -> Rx < USART > {
415- Self :: _new (
416- usart,
417- ( None :: < USART :: Tx < PushPull > > , Some ( rx_pin) ) ,
418- config,
419- clocks,
420- )
421- . split ( )
422- . 1
394+ usart. into ( ) . rx ( rx_pin, config, clocks)
423395 }
424396}
425397
@@ -439,16 +411,16 @@ impl<USART: Instance, Otype, PULL: UpMode> Serial<USART, Otype, PULL> {
439411 /// `MAPR` and `APBX` are register handles which are passed for
440412 /// configuration. (`MAPR` is used to map the USART to the
441413 /// corresponding pins. `APBX` is used to reset the USART.)
442- pub fn new (
443- usart : USART ,
414+ pub fn new < const R : u8 > (
415+ usart : impl Into < Rmp < USART , R > > ,
444416 pins : (
445- impl RInto < USART :: Tx < Otype > , 0 > ,
446- impl RInto < USART :: Rx < PULL > , 0 > ,
417+ impl RInto < USART :: Tx < Otype > , R > ,
418+ impl RInto < USART :: Rx < PULL > , R > ,
447419 ) ,
448420 config : impl Into < Config > ,
449421 clocks : & Clocks ,
450422 ) -> Self {
451- Self :: _new ( usart, ( Some ( pins . 0 ) , Some ( pins. 1 ) ) , config, clocks)
423+ usart. into ( ) . serial ( pins, config, clocks)
452424 }
453425
454426 fn _new < const R : u8 > (
0 commit comments