@@ -704,9 +704,13 @@ impl<'d, M: Mode> Usart<'d, M> {
704704 w. set_enabletx ( true ) ;
705705 w. set_enablerx ( true ) ;
706706 } ) ;
707- registers. cfg ( ) . modify ( |w| w. set_enable ( true ) ) ;
707+ registers. cfg ( ) . modify ( |w| {
708+ w. set_enable ( true ) ;
709+ } ) ;
708710
709- registers. fifointenset ( ) . modify ( |w| w. set_rxerr ( true ) ) ;
711+ registers. fifointenset ( ) . modify ( |w| {
712+ w. set_rxerr ( true ) ;
713+ } ) ;
710714
711715 // Drain RX FIFO in case it still has some unrelevant data
712716 while registers. fifostat ( ) . read ( ) . rxnotempty ( ) {
@@ -887,22 +891,63 @@ macro_rules! impl_usart_instance {
887891 } ;
888892}
889893
894+ #[ cfg( has_usart_txd_pins) ]
890895pub ( crate ) trait SealedTxPin < T : Instance > : crate :: gpio:: Pin {
891896 fn pin_func ( & self ) -> PioFunc ;
892897}
893898
899+ #[ cfg( has_usart_rxd_pins) ]
894900pub ( crate ) trait SealedRxPin < T : Instance > : crate :: gpio:: Pin {
895901 fn pin_func ( & self ) -> PioFunc ;
896902}
897903
904+ #[ cfg( has_usart_cts_pins) ]
905+ pub ( crate ) trait SealedCtsPin < T : Instance > : crate :: gpio:: Pin {
906+ // TODO(wt): This needs to be wired up in the usart driver.
907+ #[ allow( unused) ]
908+ fn pin_func ( & self ) -> PioFunc ;
909+ }
910+
911+ #[ cfg( has_usart_rts_pins) ]
912+ pub ( crate ) trait SealedRtsPin < T : Instance > : crate :: gpio:: Pin {
913+ // TODO(wt): This needs to be wired up in the usart driver.
914+ #[ allow( unused) ]
915+ fn pin_func ( & self ) -> PioFunc ;
916+ }
917+
918+ #[ cfg( has_usart_sck_pins) ]
919+ pub ( crate ) trait SealedSckPin < T : Instance > : crate :: gpio:: Pin {
920+ // TODO(wt): This needs to be wired up in the usart driver.
921+ #[ allow( unused) ]
922+ fn pin_func ( & self ) -> PioFunc ;
923+ }
924+
898925/// Trait for TX pins.
926+ #[ cfg( has_usart_txd_pins) ]
899927#[ allow( private_bounds) ]
900928pub trait TxPin < T : Instance > : SealedTxPin < T > + crate :: gpio:: Pin { }
901929
902930/// Trait for RX pins.
931+ #[ cfg( has_usart_rxd_pins) ]
903932#[ allow( private_bounds) ]
904933pub trait RxPin < T : Instance > : SealedRxPin < T > + crate :: gpio:: Pin { }
905934
935+ /// Trait for Cts pins.
936+ #[ cfg( has_usart_cts_pins) ]
937+ #[ allow( private_bounds) ]
938+ pub trait CtsPin < T : Instance > : SealedCtsPin < T > + crate :: gpio:: Pin { }
939+
940+ /// Trait for Rts pins.
941+ #[ cfg( has_usart_rts_pins) ]
942+ #[ allow( private_bounds) ]
943+ pub trait RtsPin < T : Instance > : SealedRtsPin < T > + crate :: gpio:: Pin { }
944+
945+ /// Trait for Sck pins.
946+ #[ cfg( has_usart_sck_pins) ]
947+ #[ allow( private_bounds) ]
948+ pub trait SckPin < T : Instance > : SealedSckPin < T > + crate :: gpio:: Pin { }
949+
950+ #[ cfg( has_usart_txd_pins) ]
906951macro_rules! impl_usart_txd_pin {
907952 ( $pin: ident, $instance: ident, $func: ident) => {
908953 impl crate :: usart:: SealedTxPin <crate :: peripherals:: $instance> for crate :: peripherals:: $pin {
@@ -916,6 +961,7 @@ macro_rules! impl_usart_txd_pin {
916961 } ;
917962}
918963
964+ #[ cfg( has_usart_rxd_pins) ]
919965macro_rules! impl_usart_rxd_pin {
920966 ( $pin: ident, $instance: ident, $func: ident) => {
921967 impl crate :: usart:: SealedRxPin <crate :: peripherals:: $instance> for crate :: peripherals:: $pin {
@@ -929,6 +975,48 @@ macro_rules! impl_usart_rxd_pin {
929975 } ;
930976}
931977
978+ #[ cfg( has_usart_cts_pins) ]
979+ macro_rules! impl_usart_cts_pin {
980+ ( $pin: ident, $instance: ident, $func: ident) => {
981+ impl crate :: usart:: SealedCtsPin <crate :: peripherals:: $instance> for crate :: peripherals:: $pin {
982+ fn pin_func( & self ) -> crate :: pac:: iocon:: vals:: PioFunc {
983+ use crate :: pac:: iocon:: vals:: PioFunc ;
984+ PioFunc :: $func
985+ }
986+ }
987+
988+ impl crate :: usart:: CtsPin <crate :: peripherals:: $instance> for crate :: peripherals:: $pin { }
989+ } ;
990+ }
991+
992+ #[ cfg( has_usart_rts_pins) ]
993+ macro_rules! impl_usart_rts_pin {
994+ ( $pin: ident, $instance: ident, $func: ident) => {
995+ impl crate :: usart:: SealedRtsPin <crate :: peripherals:: $instance> for crate :: peripherals:: $pin {
996+ fn pin_func( & self ) -> crate :: pac:: iocon:: vals:: PioFunc {
997+ use crate :: pac:: iocon:: vals:: PioFunc ;
998+ PioFunc :: $func
999+ }
1000+ }
1001+
1002+ impl crate :: usart:: RtsPin <crate :: peripherals:: $instance> for crate :: peripherals:: $pin { }
1003+ } ;
1004+ }
1005+
1006+ #[ cfg( has_usart_sck_pins) ]
1007+ macro_rules! impl_usart_sck_pin {
1008+ ( $pin: ident, $instance: ident, $func: ident) => {
1009+ impl crate :: usart:: SealedSckPin <crate :: peripherals:: $instance> for crate :: peripherals:: $pin {
1010+ fn pin_func( & self ) -> crate :: pac:: iocon:: vals:: PioFunc {
1011+ use crate :: pac:: iocon:: vals:: PioFunc ;
1012+ PioFunc :: $func
1013+ }
1014+ }
1015+
1016+ impl crate :: usart:: SckPin <crate :: peripherals:: $instance> for crate :: peripherals:: $pin { }
1017+ } ;
1018+ }
1019+
9321020/// Marker trait indicating a DMA channel may be used for USART transmit.
9331021pub trait TxChannel < T : Instance > : crate :: dma:: Channel { }
9341022
0 commit comments