@@ -147,29 +147,15 @@ impl<USART: Instance> SerialExt for USART {
147
147
config : impl Into < Config > ,
148
148
clocks : & Clocks ,
149
149
) -> 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)
158
151
}
159
152
fn rx < PULL : UpMode > (
160
153
self ,
161
154
rx_pin : impl RInto < Self :: Rx < PULL > , 0 > ,
162
155
config : impl Into < Config > ,
163
156
clocks : & Clocks ,
164
157
) -> 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)
173
159
}
174
160
}
175
161
@@ -388,38 +374,24 @@ impl<USART: Instance, const R: u8> Rmp<USART, R> {
388
374
}
389
375
390
376
impl < 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 > ,
394
380
config : impl Into < Config > ,
395
381
clocks : & Clocks ,
396
382
) -> 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)
405
384
}
406
385
}
407
386
408
387
impl < 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 > ,
412
391
config : impl Into < Config > ,
413
392
clocks : & Clocks ,
414
393
) -> 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)
423
395
}
424
396
}
425
397
@@ -439,16 +411,16 @@ impl<USART: Instance, Otype, PULL: UpMode> Serial<USART, Otype, PULL> {
439
411
/// `MAPR` and `APBX` are register handles which are passed for
440
412
/// configuration. (`MAPR` is used to map the USART to the
441
413
/// 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 > > ,
444
416
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 > ,
447
419
) ,
448
420
config : impl Into < Config > ,
449
421
clocks : & Clocks ,
450
422
) -> Self {
451
- Self :: _new ( usart, ( Some ( pins . 0 ) , Some ( pins. 1 ) ) , config, clocks)
423
+ usart. into ( ) . serial ( pins, config, clocks)
452
424
}
453
425
454
426
fn _new < const R : u8 > (
0 commit comments