1
1
use crate :: pac:: rcc:: cfgr:: { HPRE , SW } ;
2
+ use crate :: pac:: rcc:: RegisterBlock as RccRB ;
2
3
use crate :: pac:: { self , rcc, RCC } ;
3
4
4
5
use super :: { BusClock , BusTimerClock , RccBus } ;
@@ -9,10 +10,8 @@ use fugit::RateExtU32;
9
10
mod pll;
10
11
11
12
mod enable;
12
- use crate :: pac:: rcc:: RegisterBlock as RccRB ;
13
13
14
14
/// Enable/disable peripheral
15
- #[ allow( clippy:: missing_safety_doc) ]
16
15
pub trait Enable : RccBus {
17
16
/// Enables peripheral
18
17
fn enable ( rcc : & mut RCC ) ;
@@ -33,21 +32,20 @@ pub trait Enable: RccBus {
33
32
///
34
33
/// Enables peripheral. Takes access to RCC internally
35
34
unsafe fn enable_unchecked ( ) {
36
- let mut rcc = pac :: RCC :: steal ( ) ;
35
+ let mut rcc = RCC :: steal ( ) ;
37
36
Self :: enable ( & mut rcc) ;
38
37
}
39
38
40
39
/// # Safety
41
40
///
42
41
/// Disables peripheral. Takes access to RCC internally
43
42
unsafe fn disable_unchecked ( ) {
44
- let mut rcc = pac :: RCC :: steal ( ) ;
43
+ let mut rcc = RCC :: steal ( ) ;
45
44
Self :: disable ( & mut rcc) ;
46
45
}
47
46
}
48
47
49
48
/// Low power enable/disable peripheral
50
- #[ allow( clippy:: missing_safety_doc) ]
51
49
pub trait LPEnable : RccBus {
52
50
/// Enables peripheral in low power mode
53
51
fn enable_in_low_power ( rcc : & mut RCC ) ;
@@ -68,21 +66,20 @@ pub trait LPEnable: RccBus {
68
66
///
69
67
/// Enables peripheral in low power mode. Takes access to RCC internally
70
68
unsafe fn enable_in_low_power_unchecked ( ) {
71
- let mut rcc = pac :: RCC :: steal ( ) ;
69
+ let mut rcc = RCC :: steal ( ) ;
72
70
Self :: enable_in_low_power ( & mut rcc) ;
73
71
}
74
72
75
73
/// # Safety
76
74
///
77
75
/// Disables peripheral in low power mode. Takes access to RCC internally
78
76
unsafe fn disable_in_low_power_unchecked ( ) {
79
- let mut rcc = pac :: RCC :: steal ( ) ;
77
+ let mut rcc = RCC :: steal ( ) ;
80
78
Self :: disable_in_low_power ( & mut rcc) ;
81
79
}
82
80
}
83
81
84
82
/// Reset peripheral
85
- #[ allow( clippy:: missing_safety_doc) ]
86
83
pub trait Reset : RccBus {
87
84
/// Resets peripheral
88
85
fn reset ( rcc : & mut RCC ) ;
@@ -91,7 +88,7 @@ pub trait Reset: RccBus {
91
88
///
92
89
/// Resets peripheral. Takes access to RCC internally
93
90
unsafe fn reset_unchecked ( ) {
94
- let mut rcc = pac :: RCC :: steal ( ) ;
91
+ let mut rcc = RCC :: steal ( ) ;
95
92
Self :: reset ( & mut rcc) ;
96
93
}
97
94
}
@@ -103,14 +100,12 @@ pub trait RccExt {
103
100
}
104
101
105
102
macro_rules! bus_struct {
106
- ( $( $ ( # [ $attr : meta ] ) * $busX: ident => ( $EN: ident, $en: ident, $LPEN: ident, $lpen: ident, $RST: ident, $rst: ident, $doc: literal) , ) +) => {
103
+ ( $( $busX: ident => ( $EN: ident, $en: ident, $LPEN: ident, $lpen: ident, $RST: ident, $rst: ident, $doc: literal) , ) +) => {
107
104
$(
108
- $( #[ $attr] ) *
109
105
#[ doc = $doc]
110
106
#[ non_exhaustive]
111
107
pub struct $busX;
112
108
113
- $( #[ $attr] ) *
114
109
impl $busX {
115
110
pub ( crate ) fn enr( rcc: & RccRB ) -> & rcc:: $EN {
116
111
rcc. $en( )
@@ -132,11 +127,13 @@ bus_struct! {
132
127
APB1 => ( APB1ENR , apb1enr, APB1LPENR , apb1lpenr, APB1RSTR , apb1rstr, "Advanced Peripheral Bus 1 (APB1) registers" ) ,
133
128
APB2 => ( APB2ENR , apb2enr, APB2LPENR , apb2lpenr, APB2RSTR , apb2rstr, "Advanced Peripheral Bus 2 (APB2) registers" ) ,
134
129
AHB1 => ( AHB1ENR , ahb1enr, AHB1LPENR , ahb1lpenr, AHB1RSTR , ahb1rstr, "Advanced High-performance Bus 1 (AHB1) registers" ) ,
135
- #[ cfg( not( feature = "gpio-f410" ) ) ]
136
- AHB2 => ( AHB2ENR , ahb2enr, AHB2LPENR , ahb2lpenr, AHB2RSTR , ahb2rstr, "Advanced High-performance Bus 2 (AHB2) registers" ) ,
137
130
//#[cfg(any(feature = "fsmc", feature = "fmc"))]
138
131
//AHB3 => (AHB3ENR, ahb3enr, AHB3LPENR, ahb3lpenr, AHB3RSTR, ahb3rstr, "Advanced High-performance Bus 3 (AHB3) registers"),
139
132
}
133
+ #[ cfg( not( feature = "gpio-f410" ) ) ]
134
+ bus_struct ! {
135
+ AHB2 => ( AHB2ENR , ahb2enr, AHB2LPENR , ahb2lpenr, AHB2RSTR , ahb2rstr, "Advanced High-performance Bus 2 (AHB2) registers" ) ,
136
+ }
140
137
141
138
/// AMBA High-performance Bus 3 (AHB3) registers
142
139
#[ cfg( any( feature = "fsmc" , feature = "fmc" ) ) ]
0 commit comments