aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2022-01-04 11:18:59 +0100
committerDario Nieuwenhuis <[email protected]>2022-01-04 13:31:30 +0100
commitcdc66e110f084a27b2bae61d0611c884fcc5f845 (patch)
treef7f520602983fcaaa472d0b2619488842d39fb5b
parentf744b74e90d3bb1a571c10f0749f22132b51d303 (diff)
stm32/rcc: remove builders on Config.
This makes API consistent with other Config structs in Embassy, where the convention is to not use builders.
-rw-r--r--embassy-stm32/src/rcc/g0/mod.rs34
-rw-r--r--embassy-stm32/src/rcc/g4/mod.rs42
-rw-r--r--embassy-stm32/src/rcc/l0/mod.rs34
-rw-r--r--embassy-stm32/src/rcc/l1/mod.rs34
-rw-r--r--embassy-stm32/src/rcc/l4/mod.rs34
-rw-r--r--embassy-stm32/src/rcc/u5/mod.rs22
-rw-r--r--embassy-stm32/src/rcc/wb/mod.rs34
-rw-r--r--embassy-stm32/src/rcc/wl5x/mod.rs34
-rw-r--r--examples/stm32l0/src/bin/lorawan.rs2
-rw-r--r--examples/stm32l4/src/bin/rng.rs4
-rw-r--r--examples/stm32wl55/src/bin/lorawan.rs2
-rw-r--r--examples/stm32wl55/src/bin/subghz.rs2
12 files changed, 42 insertions, 236 deletions
diff --git a/embassy-stm32/src/rcc/g0/mod.rs b/embassy-stm32/src/rcc/g0/mod.rs
index 103d9a840..7f7af2fc9 100644
--- a/embassy-stm32/src/rcc/g0/mod.rs
+++ b/embassy-stm32/src/rcc/g0/mod.rs
@@ -102,10 +102,10 @@ impl Into<u8> for AHBPrescaler {
102 102
103/// Clocks configutation 103/// Clocks configutation
104pub struct Config { 104pub struct Config {
105 mux: ClockSrc, 105 pub mux: ClockSrc,
106 ahb_pre: AHBPrescaler, 106 pub ahb_pre: AHBPrescaler,
107 apb_pre: APBPrescaler, 107 pub apb_pre: APBPrescaler,
108 low_power_run: bool, 108 pub low_power_run: bool,
109} 109}
110 110
111impl Default for Config { 111impl Default for Config {
@@ -120,32 +120,6 @@ impl Default for Config {
120 } 120 }
121} 121}
122 122
123impl Config {
124 #[inline]
125 pub fn clock_src(mut self, mux: ClockSrc) -> Self {
126 self.mux = mux;
127 self
128 }
129
130 #[inline]
131 pub fn ahb_pre(mut self, pre: AHBPrescaler) -> Self {
132 self.ahb_pre = pre;
133 self
134 }
135
136 #[inline]
137 pub fn apb_pre(mut self, pre: APBPrescaler) -> Self {
138 self.apb_pre = pre;
139 self
140 }
141
142 #[inline]
143 pub fn low_power_run(mut self, on: bool) -> Self {
144 self.low_power_run = on;
145 self
146 }
147}
148
149/// RCC peripheral 123/// RCC peripheral
150pub struct Rcc<'d> { 124pub struct Rcc<'d> {
151 _rb: peripherals::RCC, 125 _rb: peripherals::RCC,
diff --git a/embassy-stm32/src/rcc/g4/mod.rs b/embassy-stm32/src/rcc/g4/mod.rs
index 8dd37af8e..8a75b2e03 100644
--- a/embassy-stm32/src/rcc/g4/mod.rs
+++ b/embassy-stm32/src/rcc/g4/mod.rs
@@ -74,11 +74,11 @@ impl Into<u8> for AHBPrescaler {
74 74
75/// Clocks configutation 75/// Clocks configutation
76pub struct Config { 76pub struct Config {
77 mux: ClockSrc, 77 pub mux: ClockSrc,
78 ahb_pre: AHBPrescaler, 78 pub ahb_pre: AHBPrescaler,
79 apb1_pre: APBPrescaler, 79 pub apb1_pre: APBPrescaler,
80 apb2_pre: APBPrescaler, 80 pub apb2_pre: APBPrescaler,
81 low_power_run: bool, 81 pub low_power_run: bool,
82} 82}
83 83
84impl Default for Config { 84impl Default for Config {
@@ -94,38 +94,6 @@ impl Default for Config {
94 } 94 }
95} 95}
96 96
97impl Config {
98 #[inline]
99 pub fn clock_src(mut self, mux: ClockSrc) -> Self {
100 self.mux = mux;
101 self
102 }
103
104 #[inline]
105 pub fn ahb_pre(mut self, pre: AHBPrescaler) -> Self {
106 self.ahb_pre = pre;
107 self
108 }
109
110 #[inline]
111 pub fn apb1_pre(mut self, pre: APBPrescaler) -> Self {
112 self.apb1_pre = pre;
113 self
114 }
115
116 #[inline]
117 pub fn apb2_pre(mut self, pre: APBPrescaler) -> Self {
118 self.apb2_pre = pre;
119 self
120 }
121
122 #[inline]
123 pub fn low_power_run(mut self, on: bool) -> Self {
124 self.low_power_run = on;
125 self
126 }
127}
128
129/// RCC peripheral 97/// RCC peripheral
130pub struct Rcc<'d> { 98pub struct Rcc<'d> {
131 _rb: peripherals::RCC, 99 _rb: peripherals::RCC,
diff --git a/embassy-stm32/src/rcc/l0/mod.rs b/embassy-stm32/src/rcc/l0/mod.rs
index 8af4eca08..fd84f09c5 100644
--- a/embassy-stm32/src/rcc/l0/mod.rs
+++ b/embassy-stm32/src/rcc/l0/mod.rs
@@ -183,10 +183,10 @@ impl Into<Msirange> for MSIRange {
183 183
184/// Clocks configutation 184/// Clocks configutation
185pub struct Config { 185pub struct Config {
186 mux: ClockSrc, 186 pub mux: ClockSrc,
187 ahb_pre: AHBPrescaler, 187 pub ahb_pre: AHBPrescaler,
188 apb1_pre: APBPrescaler, 188 pub apb1_pre: APBPrescaler,
189 apb2_pre: APBPrescaler, 189 pub apb2_pre: APBPrescaler,
190} 190}
191 191
192impl Default for Config { 192impl Default for Config {
@@ -201,32 +201,6 @@ impl Default for Config {
201 } 201 }
202} 202}
203 203
204impl Config {
205 #[inline]
206 pub fn clock_src(mut self, mux: ClockSrc) -> Self {
207 self.mux = mux;
208 self
209 }
210
211 #[inline]
212 pub fn ahb_pre(mut self, pre: AHBPrescaler) -> Self {
213 self.ahb_pre = pre;
214 self
215 }
216
217 #[inline]
218 pub fn apb1_pre(mut self, pre: APBPrescaler) -> Self {
219 self.apb1_pre = pre;
220 self
221 }
222
223 #[inline]
224 pub fn apb2_pre(mut self, pre: APBPrescaler) -> Self {
225 self.apb2_pre = pre;
226 self
227 }
228}
229
230/// RCC peripheral 204/// RCC peripheral
231pub struct Rcc<'d> { 205pub struct Rcc<'d> {
232 _rb: peripherals::RCC, 206 _rb: peripherals::RCC,
diff --git a/embassy-stm32/src/rcc/l1/mod.rs b/embassy-stm32/src/rcc/l1/mod.rs
index d0b52d2f4..e46bee323 100644
--- a/embassy-stm32/src/rcc/l1/mod.rs
+++ b/embassy-stm32/src/rcc/l1/mod.rs
@@ -118,10 +118,10 @@ impl Into<u8> for MSIRange {
118 118
119/// Clocks configutation 119/// Clocks configutation
120pub struct Config { 120pub struct Config {
121 mux: ClockSrc, 121 pub mux: ClockSrc,
122 ahb_pre: AHBPrescaler, 122 pub ahb_pre: AHBPrescaler,
123 apb1_pre: APBPrescaler, 123 pub apb1_pre: APBPrescaler,
124 apb2_pre: APBPrescaler, 124 pub apb2_pre: APBPrescaler,
125} 125}
126 126
127impl Default for Config { 127impl Default for Config {
@@ -136,32 +136,6 @@ impl Default for Config {
136 } 136 }
137} 137}
138 138
139impl Config {
140 #[inline]
141 pub fn clock_src(mut self, mux: ClockSrc) -> Self {
142 self.mux = mux;
143 self
144 }
145
146 #[inline]
147 pub fn ahb_pre(mut self, pre: AHBPrescaler) -> Self {
148 self.ahb_pre = pre;
149 self
150 }
151
152 #[inline]
153 pub fn apb1_pre(mut self, pre: APBPrescaler) -> Self {
154 self.apb1_pre = pre;
155 self
156 }
157
158 #[inline]
159 pub fn apb2_pre(mut self, pre: APBPrescaler) -> Self {
160 self.apb2_pre = pre;
161 self
162 }
163}
164
165/// RCC peripheral 139/// RCC peripheral
166pub struct Rcc<'d> { 140pub struct Rcc<'d> {
167 _rb: peripherals::RCC, 141 _rb: peripherals::RCC,
diff --git a/embassy-stm32/src/rcc/l4/mod.rs b/embassy-stm32/src/rcc/l4/mod.rs
index e1eadf856..a0eedf0b6 100644
--- a/embassy-stm32/src/rcc/l4/mod.rs
+++ b/embassy-stm32/src/rcc/l4/mod.rs
@@ -269,10 +269,10 @@ impl Into<u8> for AHBPrescaler {
269 269
270/// Clocks configutation 270/// Clocks configutation
271pub struct Config { 271pub struct Config {
272 mux: ClockSrc, 272 pub mux: ClockSrc,
273 ahb_pre: AHBPrescaler, 273 pub ahb_pre: AHBPrescaler,
274 apb1_pre: APBPrescaler, 274 pub apb1_pre: APBPrescaler,
275 apb2_pre: APBPrescaler, 275 pub apb2_pre: APBPrescaler,
276} 276}
277 277
278impl Default for Config { 278impl Default for Config {
@@ -287,32 +287,6 @@ impl Default for Config {
287 } 287 }
288} 288}
289 289
290impl Config {
291 #[inline]
292 pub fn clock_src(mut self, mux: ClockSrc) -> Self {
293 self.mux = mux;
294 self
295 }
296
297 #[inline]
298 pub fn ahb_pre(mut self, pre: AHBPrescaler) -> Self {
299 self.ahb_pre = pre;
300 self
301 }
302
303 #[inline]
304 pub fn apb1_pre(mut self, pre: APBPrescaler) -> Self {
305 self.apb1_pre = pre;
306 self
307 }
308
309 #[inline]
310 pub fn apb2_pre(mut self, pre: APBPrescaler) -> Self {
311 self.apb2_pre = pre;
312 self
313 }
314}
315
316/// RCC peripheral 290/// RCC peripheral
317pub struct Rcc<'d> { 291pub struct Rcc<'d> {
318 _rb: peripherals::RCC, 292 _rb: peripherals::RCC,
diff --git a/embassy-stm32/src/rcc/u5/mod.rs b/embassy-stm32/src/rcc/u5/mod.rs
index 6e68b2205..a3df3a02d 100644
--- a/embassy-stm32/src/rcc/u5/mod.rs
+++ b/embassy-stm32/src/rcc/u5/mod.rs
@@ -274,16 +274,16 @@ impl Default for MSIRange {
274 274
275#[derive(Copy, Clone)] 275#[derive(Copy, Clone)]
276pub struct Config { 276pub struct Config {
277 mux: ClockSrc, 277 pub mux: ClockSrc,
278 ahb_pre: AHBPrescaler, 278 pub ahb_pre: AHBPrescaler,
279 apb1_pre: APBPrescaler, 279 pub apb1_pre: APBPrescaler,
280 apb2_pre: APBPrescaler, 280 pub apb2_pre: APBPrescaler,
281 apb3_pre: APBPrescaler, 281 pub apb3_pre: APBPrescaler,
282} 282}
283 283
284impl Config { 284impl Default for Config {
285 pub fn new() -> Self { 285 fn default() -> Self {
286 Config { 286 Self {
287 mux: ClockSrc::MSI(MSIRange::default()), 287 mux: ClockSrc::MSI(MSIRange::default()),
288 ahb_pre: Default::default(), 288 ahb_pre: Default::default(),
289 apb1_pre: Default::default(), 289 apb1_pre: Default::default(),
@@ -293,12 +293,6 @@ impl Config {
293 } 293 }
294} 294}
295 295
296impl Default for Config {
297 fn default() -> Self {
298 Config::new()
299 }
300}
301
302/// Extension trait that freezes the `RCC` peripheral with provided clocks configuration 296/// Extension trait that freezes the `RCC` peripheral with provided clocks configuration
303pub trait RccExt { 297pub trait RccExt {
304 fn freeze(self, config: Config, power: &Power) -> Clocks; 298 fn freeze(self, config: Config, power: &Power) -> Clocks;
diff --git a/embassy-stm32/src/rcc/wb/mod.rs b/embassy-stm32/src/rcc/wb/mod.rs
index 435357418..73835cacd 100644
--- a/embassy-stm32/src/rcc/wb/mod.rs
+++ b/embassy-stm32/src/rcc/wb/mod.rs
@@ -86,10 +86,10 @@ impl Into<u8> for AHBPrescaler {
86 86
87/// Clocks configutation 87/// Clocks configutation
88pub struct Config { 88pub struct Config {
89 mux: ClockSrc, 89 pub mux: ClockSrc,
90 ahb_pre: AHBPrescaler, 90 pub ahb_pre: AHBPrescaler,
91 apb1_pre: APBPrescaler, 91 pub apb1_pre: APBPrescaler,
92 apb2_pre: APBPrescaler, 92 pub apb2_pre: APBPrescaler,
93} 93}
94 94
95impl Default for Config { 95impl Default for Config {
@@ -104,32 +104,6 @@ impl Default for Config {
104 } 104 }
105} 105}
106 106
107impl Config {
108 #[inline]
109 pub fn clock_src(mut self, mux: ClockSrc) -> Self {
110 self.mux = mux;
111 self
112 }
113
114 #[inline]
115 pub fn ahb_pre(mut self, pre: AHBPrescaler) -> Self {
116 self.ahb_pre = pre;
117 self
118 }
119
120 #[inline]
121 pub fn apb1_pre(mut self, pre: APBPrescaler) -> Self {
122 self.apb1_pre = pre;
123 self
124 }
125
126 #[inline]
127 pub fn apb2_pre(mut self, pre: APBPrescaler) -> Self {
128 self.apb2_pre = pre;
129 self
130 }
131}
132
133/// RCC peripheral 107/// RCC peripheral
134pub struct Rcc<'d> { 108pub struct Rcc<'d> {
135 _rb: peripherals::RCC, 109 _rb: peripherals::RCC,
diff --git a/embassy-stm32/src/rcc/wl5x/mod.rs b/embassy-stm32/src/rcc/wl5x/mod.rs
index aa49c99c9..1b7bfb09d 100644
--- a/embassy-stm32/src/rcc/wl5x/mod.rs
+++ b/embassy-stm32/src/rcc/wl5x/mod.rs
@@ -87,10 +87,10 @@ impl Into<u8> for AHBPrescaler {
87 87
88/// Clocks configutation 88/// Clocks configutation
89pub struct Config { 89pub struct Config {
90 mux: ClockSrc, 90 pub mux: ClockSrc,
91 ahb_pre: AHBPrescaler, 91 pub ahb_pre: AHBPrescaler,
92 apb1_pre: APBPrescaler, 92 pub apb1_pre: APBPrescaler,
93 apb2_pre: APBPrescaler, 93 pub apb2_pre: APBPrescaler,
94} 94}
95 95
96impl Default for Config { 96impl Default for Config {
@@ -105,32 +105,6 @@ impl Default for Config {
105 } 105 }
106} 106}
107 107
108impl Config {
109 #[inline]
110 pub fn clock_src(mut self, mux: ClockSrc) -> Self {
111 self.mux = mux;
112 self
113 }
114
115 #[inline]
116 pub fn ahb_pre(mut self, pre: AHBPrescaler) -> Self {
117 self.ahb_pre = pre;
118 self
119 }
120
121 #[inline]
122 pub fn apb1_pre(mut self, pre: APBPrescaler) -> Self {
123 self.apb1_pre = pre;
124 self
125 }
126
127 #[inline]
128 pub fn apb2_pre(mut self, pre: APBPrescaler) -> Self {
129 self.apb2_pre = pre;
130 self
131 }
132}
133
134/// RCC peripheral 108/// RCC peripheral
135pub struct Rcc<'d> { 109pub struct Rcc<'d> {
136 _rb: peripherals::RCC, 110 _rb: peripherals::RCC,
diff --git a/examples/stm32l0/src/bin/lorawan.rs b/examples/stm32l0/src/bin/lorawan.rs
index cbae88356..7ce859a8d 100644
--- a/examples/stm32l0/src/bin/lorawan.rs
+++ b/examples/stm32l0/src/bin/lorawan.rs
@@ -25,7 +25,7 @@ use lorawan_encoding::default_crypto::DefaultFactory as Crypto;
25 25
26fn config() -> embassy_stm32::Config { 26fn config() -> embassy_stm32::Config {
27 let mut config = embassy_stm32::Config::default(); 27 let mut config = embassy_stm32::Config::default();
28 config.rcc = config.rcc.clock_src(embassy_stm32::rcc::ClockSrc::HSI16); 28 config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSI16;
29 config 29 config
30} 30}
31 31
diff --git a/examples/stm32l4/src/bin/rng.rs b/examples/stm32l4/src/bin/rng.rs
index ee5f579f8..c60b1d8bc 100644
--- a/examples/stm32l4/src/bin/rng.rs
+++ b/examples/stm32l4/src/bin/rng.rs
@@ -14,13 +14,13 @@ use example_common::*;
14 14
15fn config() -> Config { 15fn config() -> Config {
16 let mut config = Config::default(); 16 let mut config = Config::default();
17 config.rcc = config.rcc.clock_src(ClockSrc::PLL( 17 config.rcc.mux = ClockSrc::PLL(
18 PLLSource::HSI16, 18 PLLSource::HSI16,
19 PLLClkDiv::Div2, 19 PLLClkDiv::Div2,
20 PLLSrcDiv::Div1, 20 PLLSrcDiv::Div1,
21 PLLMul::Mul8, 21 PLLMul::Mul8,
22 Some(PLLClkDiv::Div2), 22 Some(PLLClkDiv::Div2),
23 )); 23 );
24 config 24 config
25} 25}
26 26
diff --git a/examples/stm32wl55/src/bin/lorawan.rs b/examples/stm32wl55/src/bin/lorawan.rs
index 155905ae7..7048a5814 100644
--- a/examples/stm32wl55/src/bin/lorawan.rs
+++ b/examples/stm32wl55/src/bin/lorawan.rs
@@ -23,7 +23,7 @@ use lorawan_encoding::default_crypto::DefaultFactory as Crypto;
23 23
24fn config() -> embassy_stm32::Config { 24fn config() -> embassy_stm32::Config {
25 let mut config = embassy_stm32::Config::default(); 25 let mut config = embassy_stm32::Config::default();
26 config.rcc = config.rcc.clock_src(embassy_stm32::rcc::ClockSrc::HSI16); 26 config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSI16;
27 config 27 config
28} 28}
29 29
diff --git a/examples/stm32wl55/src/bin/subghz.rs b/examples/stm32wl55/src/bin/subghz.rs
index 89549c766..a73c361c2 100644
--- a/examples/stm32wl55/src/bin/subghz.rs
+++ b/examples/stm32wl55/src/bin/subghz.rs
@@ -66,7 +66,7 @@ const TX_PARAMS: TxParams = TxParams::new()
66 66
67fn config() -> embassy_stm32::Config { 67fn config() -> embassy_stm32::Config {
68 let mut config = embassy_stm32::Config::default(); 68 let mut config = embassy_stm32::Config::default();
69 config.rcc = config.rcc.clock_src(embassy_stm32::rcc::ClockSrc::HSE32); 69 config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSE32;
70 config 70 config
71} 71}
72 72