22
33use crate :: { sealed, Sealed } ;
44
5+ use super :: * ;
56#[ cfg( feature = "uart4" ) ]
67use crate :: pac:: uart4;
78use crate :: pac:: usart1;
8- use stm32f4:: { Readable , Reg , RegisterSpec , Resettable , Writable , R , W } ;
99
10- pub trait UartExt : Sealed {
10+ pub trait UartRB : Sealed {
1111 fn cr1 ( & self ) -> & usart1:: CR1 ;
1212 fn dr ( & self ) -> & usart1:: DR ;
1313 fn brr ( & self ) -> & usart1:: BRR ;
@@ -21,43 +21,6 @@ pub trait UartExt: Sealed {
2121 fn gtpr ( & self ) -> & Reg < Self :: GTPRrs > ;
2222}
2323
24- macro_rules! wrap_r {
25- ( pub trait $TrR: ident {
26- $( fn $f: ident( & self $( , $n: ident: u8 ) ?) -> $fr: path; ) *
27- } ) => {
28- pub trait $TrR {
29- $( fn $f( & self $( , $n: u8 ) ?) -> $fr; ) *
30- }
31- impl <REG : reg:: $TrR> $TrR for R <REG > {
32- $(
33- #[ inline( always) ]
34- fn $f( & self $( , $n: u8 ) ?) -> $fr {
35- REG :: $f( self $( , $n) ?)
36- }
37- ) *
38- }
39- } ;
40- }
41-
42- macro_rules! wrap_w {
43- ( pub trait $TrR: ident {
44- $( fn $f: ident( & mut self $( , $n: ident: u8 ) ?) -> $fr: path; ) *
45- } ) => {
46- pub trait $TrR<REG : reg:: $TrR> {
47- $( fn $f( & mut self $( , $n: u8 ) ?) -> $fr; ) *
48- }
49-
50- impl <REG : reg:: $TrR> $TrR<REG > for W <REG > {
51- $(
52- #[ inline( always) ]
53- fn $f( & mut self $( , $n: u8 ) ?) -> $fr {
54- REG :: $f( self $( , $n) ?)
55- }
56- ) *
57- }
58- } ;
59- }
60-
6124wrap_r ! {
6225 pub trait SrR {
6326 fn pe( & self ) -> usart1:: sr:: PE_R ;
@@ -190,42 +153,10 @@ mod reg {
190153 }
191154}
192155
193- macro_rules! impl_reg {
194- ( $( $r: ident -> & $rty: path; ) * ) => {
195- $(
196- #[ inline( always) ]
197- fn $r( & self ) -> & $rty {
198- self . $r( )
199- }
200- ) *
201- } ;
202- }
203-
204- macro_rules! impl_read {
205- ( $( $f: ident $( : $n: ident) ? -> $fty: path; ) * ) => {
206- $(
207- #[ inline( always) ]
208- fn $f( r: & R <Self > $( , $n: u8 ) ?) -> $fty {
209- r. $f( $( $n) ?)
210- }
211- ) *
212- } ;
213- }
214- macro_rules! impl_write {
215- ( $( $f: ident $( : $n: ident) ? -> $fty: path; ) * ) => {
216- $(
217- #[ inline( always) ]
218- fn $f( w: & mut W <Self > $( , $n: u8 ) ?) -> $fty {
219- w. $f( $( $n) ?)
220- }
221- ) *
222- } ;
223- }
224-
225156macro_rules! impl_ext {
226157 ( $( #[ $attr: meta] ) * $uart: ident) => {
227158 impl Sealed for $uart:: RegisterBlock { }
228- impl UartExt for $uart:: RegisterBlock {
159+ impl UartRB for $uart:: RegisterBlock {
229160 type SRrs = $uart:: sr:: SRrs ;
230161 type CR2rs = $uart:: cr2:: CR2rs ;
231162 type CR3rs = $uart:: cr3:: CR3rs ;
0 commit comments