diff options
| author | Ulf Lilleengen <[email protected]> | 2021-05-27 10:01:40 +0200 |
|---|---|---|
| committer | Ulf Lilleengen <[email protected]> | 2021-05-27 10:01:40 +0200 |
| commit | 3669eba561aa25c492e446c72899452e61e5a921 (patch) | |
| tree | b8092d47c4c1d5ef1761472f2c568716453d1acb | |
| parent | a41a8123456f29b00220ea474594255cc07f2ecf (diff) | |
Use builder
| -rw-r--r-- | embassy-stm32/src/lib.rs | 5 | ||||
| -rw-r--r-- | embassy-stm32/src/rcc/l0/mod.rs | 43 |
2 files changed, 3 insertions, 45 deletions
diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs index 49ead8506..34f065165 100644 --- a/embassy-stm32/src/lib.rs +++ b/embassy-stm32/src/lib.rs | |||
| @@ -46,8 +46,9 @@ pub struct Config { | |||
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | impl Config { | 48 | impl Config { |
| 49 | pub fn new(rcc: rcc::Config) -> Self { | 49 | pub fn rcc(mut self, rcc: rcc::Config) -> Self { |
| 50 | Self { rcc } | 50 | self.rcc = rcc; |
| 51 | self | ||
| 51 | } | 52 | } |
| 52 | } | 53 | } |
| 53 | 54 | ||
diff --git a/embassy-stm32/src/rcc/l0/mod.rs b/embassy-stm32/src/rcc/l0/mod.rs index 99055d906..0cf3c2cb7 100644 --- a/embassy-stm32/src/rcc/l0/mod.rs +++ b/embassy-stm32/src/rcc/l0/mod.rs | |||
| @@ -224,49 +224,6 @@ impl Config { | |||
| 224 | self.apb2_pre = pre; | 224 | self.apb2_pre = pre; |
| 225 | self | 225 | self |
| 226 | } | 226 | } |
| 227 | |||
| 228 | #[inline] | ||
| 229 | pub fn hsi16() -> Config { | ||
| 230 | Config { | ||
| 231 | mux: ClockSrc::HSI16, | ||
| 232 | ahb_pre: AHBPrescaler::NotDivided, | ||
| 233 | apb1_pre: APBPrescaler::NotDivided, | ||
| 234 | apb2_pre: APBPrescaler::NotDivided, | ||
| 235 | } | ||
| 236 | } | ||
| 237 | |||
| 238 | #[inline] | ||
| 239 | pub fn msi(range: MSIRange) -> Config { | ||
| 240 | Config { | ||
| 241 | mux: ClockSrc::MSI(range), | ||
| 242 | ahb_pre: AHBPrescaler::NotDivided, | ||
| 243 | apb1_pre: APBPrescaler::NotDivided, | ||
| 244 | apb2_pre: APBPrescaler::NotDivided, | ||
| 245 | } | ||
| 246 | } | ||
| 247 | |||
| 248 | #[inline] | ||
| 249 | pub fn pll(pll_src: PLLSource, pll_mul: PLLMul, pll_div: PLLDiv) -> Config { | ||
| 250 | Config { | ||
| 251 | mux: ClockSrc::PLL(pll_src, pll_mul, pll_div), | ||
| 252 | ahb_pre: AHBPrescaler::NotDivided, | ||
| 253 | apb1_pre: APBPrescaler::NotDivided, | ||
| 254 | apb2_pre: APBPrescaler::NotDivided, | ||
| 255 | } | ||
| 256 | } | ||
| 257 | |||
| 258 | #[inline] | ||
| 259 | pub fn hse<T>(freq: T) -> Config | ||
| 260 | where | ||
| 261 | T: Into<Hertz>, | ||
| 262 | { | ||
| 263 | Config { | ||
| 264 | mux: ClockSrc::HSE(freq.into()), | ||
| 265 | ahb_pre: AHBPrescaler::NotDivided, | ||
| 266 | apb1_pre: APBPrescaler::NotDivided, | ||
| 267 | apb2_pre: APBPrescaler::NotDivided, | ||
| 268 | } | ||
| 269 | } | ||
| 270 | } | 227 | } |
| 271 | 228 | ||
| 272 | /// RCC peripheral | 229 | /// RCC peripheral |
