diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-01-14 20:07:25 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-01-14 20:07:25 +0000 |
| commit | ddf8c99a938f7d2c4bb6e3ea9476c487c5b1c047 (patch) | |
| tree | e4e556a1ac2a4827709f40cb3ac92fa23126e4a5 | |
| parent | 2310003f39c916322cd3aa38fbdb8a01cd1d9fdc (diff) | |
| parent | 9fb2b5fa86e0a1b79a3c24a4b415e1c0dbed52cf (diff) | |
Merge #579
579: embassy-stm32: L1 family RCC fixes r=Dirbaio a=unrelentingtech
Co-authored-by: Greg V <[email protected]>
| -rw-r--r-- | embassy-stm32/src/rcc/l1.rs | 11 | ||||
| -rw-r--r-- | examples/stm32l1/build.rs | 30 | ||||
| -rw-r--r-- | examples/stm32l1/memory.x | 5 | ||||
| m--------- | stm32-data | 0 |
4 files changed, 9 insertions, 37 deletions
diff --git a/embassy-stm32/src/rcc/l1.rs b/embassy-stm32/src/rcc/l1.rs index 517869ca4..904e6ab5d 100644 --- a/embassy-stm32/src/rcc/l1.rs +++ b/embassy-stm32/src/rcc/l1.rs | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | use crate::pac::rcc::vals::{Hpre, Msirange, Plldiv, Pllmul, Pllsrc, Ppre, Sw}; | 1 | use crate::pac::rcc::vals::{Hpre, Msirange, Plldiv, Pllmul, Pllsrc, Ppre, Sw}; |
| 2 | use crate::pac::RCC; | 2 | use crate::pac::{FLASH, RCC}; |
| 3 | use crate::rcc::{set_freqs, Clocks}; | 3 | use crate::rcc::{set_freqs, Clocks}; |
| 4 | use crate::time::Hertz; | 4 | use crate::time::Hertz; |
| 5 | use crate::time::U32Ext; | 5 | use crate::time::U32Ext; |
| @@ -258,7 +258,7 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 258 | PLLDiv::Div3 => freq / 3, | 258 | PLLDiv::Div3 => freq / 3, |
| 259 | PLLDiv::Div4 => freq / 4, | 259 | PLLDiv::Div4 => freq / 4, |
| 260 | }; | 260 | }; |
| 261 | assert!(freq <= 32_u32.mhz().0); | 261 | assert!(freq <= 32_000_000); |
| 262 | 262 | ||
| 263 | RCC.cfgr().write(move |w| { | 263 | RCC.cfgr().write(move |w| { |
| 264 | w.set_pllmul(mul.into()); | 264 | w.set_pllmul(mul.into()); |
| @@ -274,6 +274,13 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 274 | } | 274 | } |
| 275 | }; | 275 | }; |
| 276 | 276 | ||
| 277 | // Set flash 64-bit access, prefetch and wait states | ||
| 278 | if sys_clk >= 16_000_000 { | ||
| 279 | FLASH.acr().write(|w| w.set_acc64(true)); | ||
| 280 | FLASH.acr().modify(|w| w.set_prften(true)); | ||
| 281 | FLASH.acr().modify(|w| w.set_latency(true)); | ||
| 282 | } | ||
| 283 | |||
| 277 | RCC.cfgr().modify(|w| { | 284 | RCC.cfgr().modify(|w| { |
| 278 | w.set_sw(sw); | 285 | w.set_sw(sw); |
| 279 | w.set_hpre(config.ahb_pre.into()); | 286 | w.set_hpre(config.ahb_pre.into()); |
diff --git a/examples/stm32l1/build.rs b/examples/stm32l1/build.rs index 30691aa97..8cd32d7ed 100644 --- a/examples/stm32l1/build.rs +++ b/examples/stm32l1/build.rs | |||
| @@ -1,34 +1,4 @@ | |||
| 1 | //! This build script copies the `memory.x` file from the crate root into | ||
| 2 | //! a directory where the linker can always find it at build time. | ||
| 3 | //! For many projects this is optional, as the linker always searches the | ||
| 4 | //! project root directory -- wherever `Cargo.toml` is. However, if you | ||
| 5 | //! are using a workspace or have a more complicated build setup, this | ||
| 6 | //! build script becomes required. Additionally, by requesting that | ||
| 7 | //! Cargo re-run the build script whenever `memory.x` is changed, | ||
| 8 | //! updating `memory.x` ensures a rebuild of the application with the | ||
| 9 | //! new memory settings. | ||
| 10 | |||
| 11 | use std::env; | ||
| 12 | use std::fs::File; | ||
| 13 | use std::io::Write; | ||
| 14 | use std::path::PathBuf; | ||
| 15 | |||
| 16 | fn main() { | 1 | fn main() { |
| 17 | // Put `memory.x` in our output directory and ensure it's | ||
| 18 | // on the linker search path. | ||
| 19 | let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); | ||
| 20 | File::create(out.join("memory.x")) | ||
| 21 | .unwrap() | ||
| 22 | .write_all(include_bytes!("memory.x")) | ||
| 23 | .unwrap(); | ||
| 24 | println!("cargo:rustc-link-search={}", out.display()); | ||
| 25 | |||
| 26 | // By default, Cargo will re-run a build script whenever | ||
| 27 | // any file in the project changes. By specifying `memory.x` | ||
| 28 | // here, we ensure the build script is only re-run when | ||
| 29 | // `memory.x` is changed. | ||
| 30 | println!("cargo:rerun-if-changed=memory.x"); | ||
| 31 | |||
| 32 | println!("cargo:rustc-link-arg-bins=--nmagic"); | 2 | println!("cargo:rustc-link-arg-bins=--nmagic"); |
| 33 | println!("cargo:rustc-link-arg-bins=-Tlink.x"); | 3 | println!("cargo:rustc-link-arg-bins=-Tlink.x"); |
| 34 | println!("cargo:rustc-link-arg-bins=-Tdefmt.x"); | 4 | println!("cargo:rustc-link-arg-bins=-Tdefmt.x"); |
diff --git a/examples/stm32l1/memory.x b/examples/stm32l1/memory.x deleted file mode 100644 index c94d395c8..000000000 --- a/examples/stm32l1/memory.x +++ /dev/null | |||
| @@ -1,5 +0,0 @@ | |||
| 1 | MEMORY | ||
| 2 | { | ||
| 3 | FLASH : ORIGIN = 0x08000000, LENGTH = 128K | ||
| 4 | RAM : ORIGIN = 0x20000000, LENGTH = 32K | ||
| 5 | } | ||
diff --git a/stm32-data b/stm32-data | |||
| Subproject c66033b9d220ce6d148a4c90f72acd1118861bb | Subproject 97877b42a7b14e753dcb3153221dc1f3865070d | ||
