@@ -93,6 +93,7 @@ pub struct Config {
93
93
}
94
94
95
95
impl Default for Config {
96
+ #[ inline]
96
97
fn default ( ) -> Config {
97
98
Config {
98
99
mux : ClockSrc :: MSI ( MSIRange :: default ( ) ) ,
@@ -104,26 +105,31 @@ impl Default for Config {
104
105
}
105
106
106
107
impl Config {
108
+ #[ inline]
107
109
pub fn clock_src ( mut self , mux : ClockSrc ) -> Self {
108
110
self . mux = mux;
109
111
self
110
112
}
111
113
114
+ #[ inline]
112
115
pub fn ahb_pre ( mut self , pre : AHBPrescaler ) -> Self {
113
116
self . ahb_pre = pre;
114
117
self
115
118
}
116
119
120
+ #[ inline]
117
121
pub fn apb1_pre ( mut self , pre : APBPrescaler ) -> Self {
118
122
self . apb1_pre = pre;
119
123
self
120
124
}
121
125
126
+ #[ inline]
122
127
pub fn apb2_pre ( mut self , pre : APBPrescaler ) -> Self {
123
128
self . apb2_pre = pre;
124
129
self
125
130
}
126
131
132
+ #[ inline]
127
133
pub fn hsi16 ( ) -> Config {
128
134
Config {
129
135
mux : ClockSrc :: HSI16 ,
@@ -133,6 +139,7 @@ impl Config {
133
139
}
134
140
}
135
141
142
+ #[ inline]
136
143
pub fn msi ( range : MSIRange ) -> Config {
137
144
Config {
138
145
mux : ClockSrc :: MSI ( range) ,
@@ -142,6 +149,7 @@ impl Config {
142
149
}
143
150
}
144
151
152
+ #[ inline]
145
153
pub fn pll ( pll_src : PLLSource , pll_mul : PLLMul , pll_div : PLLDiv ) -> Config {
146
154
Config {
147
155
mux : ClockSrc :: PLL ( pll_src, pll_mul, pll_div) ,
@@ -151,6 +159,7 @@ impl Config {
151
159
}
152
160
}
153
161
162
+ #[ inline]
154
163
pub fn hse < T > ( freq : T ) -> Config
155
164
where
156
165
T : Into < Hertz > ,
@@ -176,6 +185,10 @@ pub trait RccExt {
176
185
}
177
186
178
187
impl RccExt for RCC {
188
+ // `cfgr` is almost always a constant, so make sure it can be constant-propagated properly by
189
+ // marking this function and all `Config` constructors and setters as `#[inline]`.
190
+ // This saves ~900 Bytes for the `pwr.rs` example.
191
+ #[ inline]
179
192
fn freeze ( self , cfgr : Config ) -> Rcc {
180
193
let ( sys_clk, sw_bits) = match cfgr. mux {
181
194
ClockSrc :: MSI ( range) => {
0 commit comments