@@ -100,6 +100,7 @@ pub struct Config {
100
100
}
101
101
102
102
impl Default for Config {
103
+ #[ inline]
103
104
fn default ( ) -> Config {
104
105
Config {
105
106
mux : ClockSrc :: MSI ( MSIRange :: default ( ) ) ,
@@ -111,26 +112,31 @@ impl Default for Config {
111
112
}
112
113
113
114
impl Config {
115
+ #[ inline]
114
116
pub fn clock_src ( mut self , mux : ClockSrc ) -> Self {
115
117
self . mux = mux;
116
118
self
117
119
}
118
120
121
+ #[ inline]
119
122
pub fn ahb_pre ( mut self , pre : AHBPrescaler ) -> Self {
120
123
self . ahb_pre = pre;
121
124
self
122
125
}
123
126
127
+ #[ inline]
124
128
pub fn apb1_pre ( mut self , pre : APBPrescaler ) -> Self {
125
129
self . apb1_pre = pre;
126
130
self
127
131
}
128
132
133
+ #[ inline]
129
134
pub fn apb2_pre ( mut self , pre : APBPrescaler ) -> Self {
130
135
self . apb2_pre = pre;
131
136
self
132
137
}
133
138
139
+ #[ inline]
134
140
pub fn hsi16 ( ) -> Config {
135
141
Config {
136
142
mux : ClockSrc :: HSI16 ,
@@ -140,6 +146,7 @@ impl Config {
140
146
}
141
147
}
142
148
149
+ #[ inline]
143
150
pub fn msi ( range : MSIRange ) -> Config {
144
151
Config {
145
152
mux : ClockSrc :: MSI ( range) ,
@@ -149,6 +156,7 @@ impl Config {
149
156
}
150
157
}
151
158
159
+ #[ inline]
152
160
pub fn pll ( pll_src : PLLSource , pll_mul : PLLMul , pll_div : PLLDiv ) -> Config {
153
161
Config {
154
162
mux : ClockSrc :: PLL ( pll_src, pll_mul, pll_div) ,
@@ -158,6 +166,7 @@ impl Config {
158
166
}
159
167
}
160
168
169
+ #[ inline]
161
170
pub fn hse < T > ( freq : T ) -> Config
162
171
where
163
172
T : Into < Hertz > ,
@@ -222,6 +231,10 @@ pub trait RccExt {
222
231
}
223
232
224
233
impl RccExt for RCC {
234
+ // `cfgr` is almost always a constant, so make sure it can be constant-propagated properly by
235
+ // marking this function and all `Config` constructors and setters as `#[inline]`.
236
+ // This saves ~900 Bytes for the `pwr.rs` example.
237
+ #[ inline]
225
238
fn freeze ( self , cfgr : Config ) -> Rcc {
226
239
let ( sys_clk, sw_bits) = match cfgr. mux {
227
240
ClockSrc :: MSI ( range) => {
0 commit comments