aboutsummaryrefslogtreecommitdiff
path: root/examples/stm32h7/src/bin/fmc.rs
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2022-06-12 22:15:44 +0200
committerDario Nieuwenhuis <[email protected]>2022-06-12 22:22:31 +0200
commita8703b75988e1e700af701116464025679d2feb8 (patch)
treef4ec5de70ec05e793a774049e010935ac45853ed /examples/stm32h7/src/bin/fmc.rs
parent6199bdea710cde33e5d5381b6d6abfc8af46df19 (diff)
Run rustfmt.
Diffstat (limited to 'examples/stm32h7/src/bin/fmc.rs')
-rw-r--r--examples/stm32h7/src/bin/fmc.rs21
1 files changed, 5 insertions, 16 deletions
diff --git a/examples/stm32h7/src/bin/fmc.rs b/examples/stm32h7/src/bin/fmc.rs
index ba8215d6a..2f55479c1 100644
--- a/examples/stm32h7/src/bin/fmc.rs
+++ b/examples/stm32h7/src/bin/fmc.rs
@@ -3,14 +3,12 @@
3#![feature(type_alias_impl_trait)] 3#![feature(type_alias_impl_trait)]
4 4
5use defmt::*; 5use defmt::*;
6use defmt_rtt as _; // global logger
7use embassy::executor::Spawner; 6use embassy::executor::Spawner;
8use embassy::time::{Delay, Duration, Timer}; 7use embassy::time::{Delay, Duration, Timer};
9use embassy_stm32::fmc::Fmc; 8use embassy_stm32::fmc::Fmc;
10use embassy_stm32::time::U32Ext; 9use embassy_stm32::time::U32Ext;
11use embassy_stm32::Config; 10use embassy_stm32::{Config, Peripherals};
12use embassy_stm32::Peripherals; 11use {defmt_rtt as _, panic_probe as _};
13use panic_probe as _;
14 12
15pub fn config() -> Config { 13pub fn config() -> Config {
16 let mut config = Config::default(); 14 let mut config = Config::default();
@@ -62,16 +60,8 @@ async fn main(_spawner: Spawner, p: Peripherals) {
62 const REGION_WRITE_BACK: u32 = 0x01; 60 const REGION_WRITE_BACK: u32 = 0x01;
63 const REGION_ENABLE: u32 = 0x01; 61 const REGION_ENABLE: u32 = 0x01;
64 62
65 crate::assert_eq!( 63 crate::assert_eq!(size & (size - 1), 0, "SDRAM memory region size must be a power of 2");
66 size & (size - 1), 64 crate::assert_eq!(size & 0x1F, 0, "SDRAM memory region size must be 32 bytes or more");
67 0,
68 "SDRAM memory region size must be a power of 2"
69 );
70 crate::assert_eq!(
71 size & 0x1F,
72 0,
73 "SDRAM memory region size must be 32 bytes or more"
74 );
75 fn log2minus1(sz: u32) -> u32 { 65 fn log2minus1(sz: u32) -> u32 {
76 for i in 5..=31 { 66 for i in 5..=31 {
77 if sz == (1 << i) { 67 if sz == (1 << i) {
@@ -104,8 +94,7 @@ async fn main(_spawner: Spawner, p: Peripherals) {
104 94
105 // Enable 95 // Enable
106 unsafe { 96 unsafe {
107 mpu.ctrl 97 mpu.ctrl.modify(|r| r | MPU_DEFAULT_MMAP_FOR_PRIVILEGED | MPU_ENABLE);
108 .modify(|r| r | MPU_DEFAULT_MMAP_FOR_PRIVILEGED | MPU_ENABLE);
109 98
110 scb.shcsr.modify(|r| r | MEMFAULTENA); 99 scb.shcsr.modify(|r| r | MEMFAULTENA);
111 100