diff options
| author | Ulf Lilleengen <[email protected]> | 2021-06-07 12:19:09 +0200 |
|---|---|---|
| committer | Ulf Lilleengen <[email protected]> | 2021-06-07 12:19:09 +0200 |
| commit | 1cd2c55b7cd72ac12ca3f06e581eda9216c336c0 (patch) | |
| tree | 7e6f1dcf16c8329f36114740d8f27e845c5038b3 | |
| parent | f5e2fb9a5a62f90d83ec9d312d6c471a21fbe7c6 (diff) | |
Fix stm32l0 build
| -rw-r--r-- | embassy-stm32/src/clock.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32/src/rcc/l0/mod.rs | 37 |
2 files changed, 18 insertions, 21 deletions
diff --git a/embassy-stm32/src/clock.rs b/embassy-stm32/src/clock.rs index 075b80118..7f478e790 100644 --- a/embassy-stm32/src/clock.rs +++ b/embassy-stm32/src/clock.rs | |||
| @@ -83,7 +83,7 @@ impl<T: Instance> Clock<T> { | |||
| 83 | unsafe { | 83 | unsafe { |
| 84 | let rcc = crate::pac::RCC; | 84 | let rcc = crate::pac::RCC; |
| 85 | rcc.apb1enr() | 85 | rcc.apb1enr() |
| 86 | .modify(|w| w.set_tim2en(crate::pac::rcc::vals::Lptimen::ENABLED)); | 86 | .modify(|w| w.set_tim2en(true)); |
| 87 | rcc.apb1rstr().modify(|w| w.set_tim2rst(true)); | 87 | rcc.apb1rstr().modify(|w| w.set_tim2rst(true)); |
| 88 | rcc.apb1rstr().modify(|w| w.set_tim2rst(false)); | 88 | rcc.apb1rstr().modify(|w| w.set_tim2rst(false)); |
| 89 | } | 89 | } |
diff --git a/embassy-stm32/src/rcc/l0/mod.rs b/embassy-stm32/src/rcc/l0/mod.rs index a8be72033..1d920104f 100644 --- a/embassy-stm32/src/rcc/l0/mod.rs +++ b/embassy-stm32/src/rcc/l0/mod.rs | |||
| @@ -7,9 +7,7 @@ use core::marker::PhantomData; | |||
| 7 | use embassy::util::Unborrow; | 7 | use embassy::util::Unborrow; |
| 8 | use embassy_extras::unborrow; | 8 | use embassy_extras::unborrow; |
| 9 | use pac::dbg::vals::{DbgSleep, DbgStandby, DbgStop}; | 9 | use pac::dbg::vals::{DbgSleep, DbgStandby, DbgStop}; |
| 10 | use pac::rcc::vals::{ | 10 | use pac::rcc::vals::{Hpre, Msirange, Plldiv, Pllmul, Pllsrc, Ppre, Sw}; |
| 11 | Crypen, Dbgen, Hpre, Iophen, Lptimen, Msirange, Plldiv, Pllmul, Pllon, Pllsrc, Ppre, Sw, | ||
| 12 | }; | ||
| 13 | 11 | ||
| 14 | /// Most of clock setup is copied from stm32l0xx-hal, and adopted to the generated PAC, | 12 | /// Most of clock setup is copied from stm32l0xx-hal, and adopted to the generated PAC, |
| 15 | /// and with the addition of the init function to configure a system clock. | 13 | /// and with the addition of the init function to configure a system clock. |
| @@ -266,7 +264,7 @@ impl<'d> Rcc<'d> { | |||
| 266 | // NOTE(unsafe) We have exclusive access to the RCC and DBGMCU | 264 | // NOTE(unsafe) We have exclusive access to the RCC and DBGMCU |
| 267 | unsafe { | 265 | unsafe { |
| 268 | if enable_dma { | 266 | if enable_dma { |
| 269 | pac::RCC.ahbenr().modify(|w| w.set_dmaen(Crypen::ENABLED)); | 267 | pac::RCC.ahbenr().modify(|w| w.set_dmaen(true)); |
| 270 | } | 268 | } |
| 271 | 269 | ||
| 272 | pac::DBGMCU.cr().modify(|w| { | 270 | pac::DBGMCU.cr().modify(|w| { |
| @@ -285,14 +283,14 @@ impl<'d> Rcc<'d> { | |||
| 285 | rcc.apb2rstr().modify(|w| w.set_syscfgrst(false)); | 283 | rcc.apb2rstr().modify(|w| w.set_syscfgrst(false)); |
| 286 | 284 | ||
| 287 | // Enable SYSCFG peripheral | 285 | // Enable SYSCFG peripheral |
| 288 | rcc.apb2enr().modify(|w| w.set_syscfgen(Dbgen::ENABLED)); | 286 | rcc.apb2enr().modify(|w| w.set_syscfgen(true)); |
| 289 | 287 | ||
| 290 | // Reset CRS peripheral | 288 | // Reset CRS peripheral |
| 291 | rcc.apb1rstr().modify(|w| w.set_crsrst(true)); | 289 | rcc.apb1rstr().modify(|w| w.set_crsrst(true)); |
| 292 | rcc.apb1rstr().modify(|w| w.set_crsrst(false)); | 290 | rcc.apb1rstr().modify(|w| w.set_crsrst(false)); |
| 293 | 291 | ||
| 294 | // Enable CRS peripheral | 292 | // Enable CRS peripheral |
| 295 | rcc.apb1enr().modify(|w| w.set_crsen(Lptimen::ENABLED)); | 293 | rcc.apb1enr().modify(|w| w.set_crsen(true)); |
| 296 | 294 | ||
| 297 | // Initialize CRS | 295 | // Initialize CRS |
| 298 | let crs = pac::CRS; | 296 | let crs = pac::CRS; |
| @@ -369,7 +367,7 @@ impl RccExt for RCC { | |||
| 369 | 367 | ||
| 370 | // Enable MSI | 368 | // Enable MSI |
| 371 | unsafe { | 369 | unsafe { |
| 372 | rcc.cr().write(|w| w.set_msion(Pllon::ENABLED)); | 370 | rcc.cr().write(|w| w.set_msion(true)); |
| 373 | while !rcc.cr().read().msirdy() {} | 371 | while !rcc.cr().read().msirdy() {} |
| 374 | } | 372 | } |
| 375 | 373 | ||
| @@ -379,7 +377,7 @@ impl RccExt for RCC { | |||
| 379 | ClockSrc::HSI16 => { | 377 | ClockSrc::HSI16 => { |
| 380 | // Enable HSI16 | 378 | // Enable HSI16 |
| 381 | unsafe { | 379 | unsafe { |
| 382 | rcc.cr().write(|w| w.set_hsi16on(Pllon::ENABLED)); | 380 | rcc.cr().write(|w| w.set_hsi16on(true)); |
| 383 | while !rcc.cr().read().hsi16rdyf() {} | 381 | while !rcc.cr().read().hsi16rdyf() {} |
| 384 | } | 382 | } |
| 385 | 383 | ||
| @@ -388,7 +386,7 @@ impl RccExt for RCC { | |||
| 388 | ClockSrc::HSE(freq) => { | 386 | ClockSrc::HSE(freq) => { |
| 389 | // Enable HSE | 387 | // Enable HSE |
| 390 | unsafe { | 388 | unsafe { |
| 391 | rcc.cr().write(|w| w.set_hseon(Pllon::ENABLED)); | 389 | rcc.cr().write(|w| w.set_hseon(true)); |
| 392 | while !rcc.cr().read().hserdy() {} | 390 | while !rcc.cr().read().hserdy() {} |
| 393 | } | 391 | } |
| 394 | 392 | ||
| @@ -399,7 +397,7 @@ impl RccExt for RCC { | |||
| 399 | PLLSource::HSE(freq) => { | 397 | PLLSource::HSE(freq) => { |
| 400 | // Enable HSE | 398 | // Enable HSE |
| 401 | unsafe { | 399 | unsafe { |
| 402 | rcc.cr().write(|w| w.set_hseon(Pllon::ENABLED)); | 400 | rcc.cr().write(|w| w.set_hseon(true)); |
| 403 | while !rcc.cr().read().hserdy() {} | 401 | while !rcc.cr().read().hserdy() {} |
| 404 | } | 402 | } |
| 405 | freq.0 | 403 | freq.0 |
| @@ -407,7 +405,7 @@ impl RccExt for RCC { | |||
| 407 | PLLSource::HSI16 => { | 405 | PLLSource::HSI16 => { |
| 408 | // Enable HSI | 406 | // Enable HSI |
| 409 | unsafe { | 407 | unsafe { |
| 410 | rcc.cr().write(|w| w.set_hsi16on(Pllon::ENABLED)); | 408 | rcc.cr().write(|w| w.set_hsi16on(true)); |
| 411 | while !rcc.cr().read().hsi16rdyf() {} | 409 | while !rcc.cr().read().hsi16rdyf() {} |
| 412 | } | 410 | } |
| 413 | HSI_FREQ | 411 | HSI_FREQ |
| @@ -416,7 +414,7 @@ impl RccExt for RCC { | |||
| 416 | 414 | ||
| 417 | // Disable PLL | 415 | // Disable PLL |
| 418 | unsafe { | 416 | unsafe { |
| 419 | rcc.cr().modify(|w| w.set_pllon(Pllon::DISABLED)); | 417 | rcc.cr().modify(|w| w.set_pllon(false)); |
| 420 | while rcc.cr().read().pllrdy() {} | 418 | while rcc.cr().read().pllrdy() {} |
| 421 | } | 419 | } |
| 422 | 420 | ||
| @@ -447,7 +445,7 @@ impl RccExt for RCC { | |||
| 447 | }); | 445 | }); |
| 448 | 446 | ||
| 449 | // Enable PLL | 447 | // Enable PLL |
| 450 | rcc.cr().modify(|w| w.set_pllon(Pllon::ENABLED)); | 448 | rcc.cr().modify(|w| w.set_pllon(true)); |
| 451 | while !rcc.cr().read().pllrdy() {} | 449 | while !rcc.cr().read().pllrdy() {} |
| 452 | } | 450 | } |
| 453 | 451 | ||
| @@ -526,14 +524,13 @@ pub struct LSE(()); | |||
| 526 | 524 | ||
| 527 | pub unsafe fn init(config: Config) { | 525 | pub unsafe fn init(config: Config) { |
| 528 | let rcc = pac::RCC; | 526 | let rcc = pac::RCC; |
| 529 | let enabled = Iophen::ENABLED; | ||
| 530 | rcc.iopenr().write(|w| { | 527 | rcc.iopenr().write(|w| { |
| 531 | w.set_iopaen(enabled); | 528 | w.set_iopaen(true); |
| 532 | w.set_iopben(enabled); | 529 | w.set_iopben(true); |
| 533 | w.set_iopcen(enabled); | 530 | w.set_iopcen(true); |
| 534 | w.set_iopden(enabled); | 531 | w.set_iopden(true); |
| 535 | w.set_iopeen(enabled); | 532 | w.set_iopeen(true); |
| 536 | w.set_iophen(enabled); | 533 | w.set_iophen(true); |
| 537 | }); | 534 | }); |
| 538 | 535 | ||
| 539 | let r = <peripherals::RCC as embassy::util::Steal>::steal(); | 536 | let r = <peripherals::RCC as embassy::util::Steal>::steal(); |
