diff options
| author | Dario Nieuwenhuis <[email protected]> | 2022-06-12 22:15:44 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-06-12 22:22:31 +0200 |
| commit | a8703b75988e1e700af701116464025679d2feb8 (patch) | |
| tree | f4ec5de70ec05e793a774049e010935ac45853ed /examples/stm32h7/src | |
| parent | 6199bdea710cde33e5d5381b6d6abfc8af46df19 (diff) | |
Run rustfmt.
Diffstat (limited to 'examples/stm32h7/src')
| -rw-r--r-- | examples/stm32h7/src/bin/adc.rs | 6 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/blinky.rs | 3 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/button_exti.rs | 3 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/camera.rs | 40 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/dac.rs | 4 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/eth.rs | 7 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/flash.rs | 11 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/fmc.rs | 21 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/low_level_timer_api.rs | 26 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/mco.rs | 3 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/pwm.rs | 6 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/rng.rs | 3 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/sdmmc.rs | 4 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/signal.rs | 7 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/spi.rs | 8 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/spi_dma.rs | 8 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/usart.rs | 6 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/usart_dma.rs | 7 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/usart_split.rs | 11 |
19 files changed, 54 insertions, 130 deletions
diff --git a/examples/stm32h7/src/bin/adc.rs b/examples/stm32h7/src/bin/adc.rs index b12bca307..e24390741 100644 --- a/examples/stm32h7/src/bin/adc.rs +++ b/examples/stm32h7/src/bin/adc.rs | |||
| @@ -2,16 +2,14 @@ | |||
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | ||
| 5 | use embassy::executor::Spawner; | 6 | use embassy::executor::Spawner; |
| 6 | use embassy::time::{Delay, Duration, Timer}; | 7 | use embassy::time::{Delay, Duration, Timer}; |
| 7 | use embassy_stm32::adc::{Adc, SampleTime}; | 8 | use embassy_stm32::adc::{Adc, SampleTime}; |
| 8 | use embassy_stm32::rcc::AdcClockSource; | 9 | use embassy_stm32::rcc::AdcClockSource; |
| 9 | use embassy_stm32::time::U32Ext; | 10 | use embassy_stm32::time::U32Ext; |
| 10 | use embassy_stm32::{Config, Peripherals}; | 11 | use embassy_stm32::{Config, Peripherals}; |
| 11 | 12 | use {defmt_rtt as _, panic_probe as _}; | |
| 12 | use defmt::*; | ||
| 13 | use defmt_rtt as _; // global logger | ||
| 14 | use panic_probe as _; | ||
| 15 | 13 | ||
| 16 | pub fn config() -> Config { | 14 | pub fn config() -> Config { |
| 17 | let mut config = Config::default(); | 15 | let mut config = Config::default(); |
diff --git a/examples/stm32h7/src/bin/blinky.rs b/examples/stm32h7/src/bin/blinky.rs index 2329125a6..7982f4a0b 100644 --- a/examples/stm32h7/src/bin/blinky.rs +++ b/examples/stm32h7/src/bin/blinky.rs | |||
| @@ -3,12 +3,11 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use defmt_rtt as _; // global logger | ||
| 7 | use embassy::executor::Spawner; | 6 | use embassy::executor::Spawner; |
| 8 | use embassy::time::{Duration, Timer}; | 7 | use embassy::time::{Duration, Timer}; |
| 9 | use embassy_stm32::gpio::{Level, Output, Speed}; | 8 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 10 | use embassy_stm32::Peripherals; | 9 | use embassy_stm32::Peripherals; |
| 11 | use panic_probe as _; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 11 | ||
| 13 | #[embassy::main] | 12 | #[embassy::main] |
| 14 | async fn main(_spawner: Spawner, p: Peripherals) { | 13 | async fn main(_spawner: Spawner, p: Peripherals) { |
diff --git a/examples/stm32h7/src/bin/button_exti.rs b/examples/stm32h7/src/bin/button_exti.rs index 78f2e6ee2..24ece9927 100644 --- a/examples/stm32h7/src/bin/button_exti.rs +++ b/examples/stm32h7/src/bin/button_exti.rs | |||
| @@ -3,12 +3,11 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use defmt_rtt as _; // global logger | ||
| 7 | use embassy::executor::Spawner; | 6 | use embassy::executor::Spawner; |
| 8 | use embassy_stm32::exti::ExtiInput; | 7 | use embassy_stm32::exti::ExtiInput; |
| 9 | use embassy_stm32::gpio::{Input, Pull}; | 8 | use embassy_stm32::gpio::{Input, Pull}; |
| 10 | use embassy_stm32::Peripherals; | 9 | use embassy_stm32::Peripherals; |
| 11 | use panic_probe as _; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 11 | ||
| 13 | #[embassy::main] | 12 | #[embassy::main] |
| 14 | async fn main(_spawner: Spawner, p: Peripherals) { | 13 | async fn main(_spawner: Spawner, p: Peripherals) { |
diff --git a/examples/stm32h7/src/bin/camera.rs b/examples/stm32h7/src/bin/camera.rs index 3311ba858..918eab659 100644 --- a/examples/stm32h7/src/bin/camera.rs +++ b/examples/stm32h7/src/bin/camera.rs | |||
| @@ -7,14 +7,10 @@ use embassy::time::{Duration, Timer}; | |||
| 7 | use embassy_stm32::dcmi::{self, *}; | 7 | use embassy_stm32::dcmi::{self, *}; |
| 8 | use embassy_stm32::gpio::{Level, Output, Speed}; | 8 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 9 | use embassy_stm32::i2c::I2c; | 9 | use embassy_stm32::i2c::I2c; |
| 10 | use embassy_stm32::interrupt; | ||
| 11 | use embassy_stm32::rcc::{Mco, Mco1Source, McoClock}; | 10 | use embassy_stm32::rcc::{Mco, Mco1Source, McoClock}; |
| 12 | use embassy_stm32::time::U32Ext; | 11 | use embassy_stm32::time::U32Ext; |
| 13 | use embassy_stm32::Config; | 12 | use embassy_stm32::{interrupt, Config, Peripherals}; |
| 14 | use embassy_stm32::Peripherals; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 15 | |||
| 16 | use defmt_rtt as _; // global logger | ||
| 17 | use panic_probe as _; | ||
| 18 | 14 | ||
| 19 | #[allow(unused)] | 15 | #[allow(unused)] |
| 20 | pub fn config() -> Config { | 16 | pub fn config() -> Config { |
| @@ -43,15 +39,7 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 43 | 39 | ||
| 44 | let mut led = Output::new(p.PE3, Level::High, Speed::Low); | 40 | let mut led = Output::new(p.PE3, Level::High, Speed::Low); |
| 45 | let i2c_irq = interrupt::take!(I2C1_EV); | 41 | let i2c_irq = interrupt::take!(I2C1_EV); |
| 46 | let cam_i2c = I2c::new( | 42 | let cam_i2c = I2c::new(p.I2C1, p.PB8, p.PB9, i2c_irq, p.DMA1_CH1, p.DMA1_CH2, 100u32.khz()); |
| 47 | p.I2C1, | ||
| 48 | p.PB8, | ||
| 49 | p.PB9, | ||
| 50 | i2c_irq, | ||
| 51 | p.DMA1_CH1, | ||
| 52 | p.DMA1_CH2, | ||
| 53 | 100u32.khz(), | ||
| 54 | ); | ||
| 55 | 43 | ||
| 56 | let mut camera = Ov7725::new(cam_i2c, mco); | 44 | let mut camera = Ov7725::new(cam_i2c, mco); |
| 57 | 45 | ||
| @@ -60,17 +48,13 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 60 | let manufacturer_id = defmt::unwrap!(camera.read_manufacturer_id().await); | 48 | let manufacturer_id = defmt::unwrap!(camera.read_manufacturer_id().await); |
| 61 | let camera_id = defmt::unwrap!(camera.read_product_id().await); | 49 | let camera_id = defmt::unwrap!(camera.read_product_id().await); |
| 62 | 50 | ||
| 63 | defmt::info!( | 51 | defmt::info!("manufacturer: 0x{:x}, pid: 0x{:x}", manufacturer_id, camera_id); |
| 64 | "manufacturer: 0x{:x}, pid: 0x{:x}", | ||
| 65 | manufacturer_id, | ||
| 66 | camera_id | ||
| 67 | ); | ||
| 68 | 52 | ||
| 69 | let dcmi_irq = interrupt::take!(DCMI); | 53 | let dcmi_irq = interrupt::take!(DCMI); |
| 70 | let config = dcmi::Config::default(); | 54 | let config = dcmi::Config::default(); |
| 71 | let mut dcmi = Dcmi::new_8bit( | 55 | let mut dcmi = Dcmi::new_8bit( |
| 72 | p.DCMI, p.DMA1_CH0, dcmi_irq, p.PC6, p.PC7, p.PE0, p.PE1, p.PE4, p.PD3, p.PE5, p.PE6, | 56 | p.DCMI, p.DMA1_CH0, dcmi_irq, p.PC6, p.PC7, p.PE0, p.PE1, p.PE4, p.PD3, p.PE5, p.PE6, p.PB7, p.PA4, p.PA6, |
| 73 | p.PB7, p.PA4, p.PA6, config, | 57 | config, |
| 74 | ); | 58 | ); |
| 75 | 59 | ||
| 76 | defmt::info!("attempting capture"); | 60 | defmt::info!("attempting capture"); |
| @@ -258,10 +242,8 @@ mod ov7725 { | |||
| 258 | let com3 = self.read(Register::Com3).await?; | 242 | let com3 = self.read(Register::Com3).await?; |
| 259 | let vflip = com3 & 0x80 > 0; | 243 | let vflip = com3 & 0x80 > 0; |
| 260 | 244 | ||
| 261 | self.modify(Register::HRef, |reg| { | 245 | self.modify(Register::HRef, |reg| reg & 0xbf | if vflip { 0x40 } else { 0x40 }) |
| 262 | reg & 0xbf | if vflip { 0x40 } else { 0x40 } | 246 | .await?; |
| 263 | }) | ||
| 264 | .await?; | ||
| 265 | 247 | ||
| 266 | if horizontal <= 320 || vertical <= 240 { | 248 | if horizontal <= 320 || vertical <= 240 { |
| 267 | self.write(Register::HStart, 0x3f).await?; | 249 | self.write(Register::HStart, 0x3f).await?; |
| @@ -291,11 +273,7 @@ mod ov7725 { | |||
| 291 | .map_err(Error::I2c) | 273 | .map_err(Error::I2c) |
| 292 | } | 274 | } |
| 293 | 275 | ||
| 294 | async fn modify<F: FnOnce(u8) -> u8>( | 276 | async fn modify<F: FnOnce(u8) -> u8>(&mut self, register: Register, f: F) -> Result<(), Error<Bus::Error>> { |
| 295 | &mut self, | ||
| 296 | register: Register, | ||
| 297 | f: F, | ||
| 298 | ) -> Result<(), Error<Bus::Error>> { | ||
| 299 | let value = self.read(register).await?; | 277 | let value = self.read(register).await?; |
| 300 | let value = f(value); | 278 | let value = f(value); |
| 301 | self.write(register, value).await | 279 | self.write(register, value).await |
diff --git a/examples/stm32h7/src/bin/dac.rs b/examples/stm32h7/src/bin/dac.rs index 86c874a6a..8ed33350c 100644 --- a/examples/stm32h7/src/bin/dac.rs +++ b/examples/stm32h7/src/bin/dac.rs | |||
| @@ -2,14 +2,12 @@ | |||
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt_rtt as _; // global logger | ||
| 6 | use panic_probe as _; | ||
| 7 | |||
| 8 | use cortex_m_rt::entry; | 5 | use cortex_m_rt::entry; |
| 9 | use defmt::*; | 6 | use defmt::*; |
| 10 | use embassy_stm32::dac::{Channel, Dac, Value}; | 7 | use embassy_stm32::dac::{Channel, Dac, Value}; |
| 11 | use embassy_stm32::time::U32Ext; | 8 | use embassy_stm32::time::U32Ext; |
| 12 | use embassy_stm32::Config; | 9 | use embassy_stm32::Config; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | ||
| 13 | 11 | ||
| 14 | pub fn config() -> Config { | 12 | pub fn config() -> Config { |
| 15 | let mut config = Config::default(); | 13 | let mut config = Config::default(); |
diff --git a/examples/stm32h7/src/bin/eth.rs b/examples/stm32h7/src/bin/eth.rs index 649ff2605..6dabadc4b 100644 --- a/examples/stm32h7/src/bin/eth.rs +++ b/examples/stm32h7/src/bin/eth.rs | |||
| @@ -13,13 +13,10 @@ use embassy_stm32::eth::{Ethernet, State}; | |||
| 13 | use embassy_stm32::peripherals::ETH; | 13 | use embassy_stm32::peripherals::ETH; |
| 14 | use embassy_stm32::rng::Rng; | 14 | use embassy_stm32::rng::Rng; |
| 15 | use embassy_stm32::time::U32Ext; | 15 | use embassy_stm32::time::U32Ext; |
| 16 | use embassy_stm32::Config; | 16 | use embassy_stm32::{interrupt, Config, Peripherals}; |
| 17 | use embassy_stm32::{interrupt, Peripherals}; | ||
| 18 | use embedded_io::asynch::Write; | 17 | use embedded_io::asynch::Write; |
| 19 | |||
| 20 | use defmt_rtt as _; // global logger | ||
| 21 | use panic_probe as _; | ||
| 22 | use rand_core::RngCore; | 18 | use rand_core::RngCore; |
| 19 | use {defmt_rtt as _, panic_probe as _}; | ||
| 23 | 20 | ||
| 24 | macro_rules! forever { | 21 | macro_rules! forever { |
| 25 | ($val:expr) => {{ | 22 | ($val:expr) => {{ |
diff --git a/examples/stm32h7/src/bin/flash.rs b/examples/stm32h7/src/bin/flash.rs index b008c0884..5f97d2b31 100644 --- a/examples/stm32h7/src/bin/flash.rs +++ b/examples/stm32h7/src/bin/flash.rs | |||
| @@ -3,13 +3,12 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::{info, unwrap}; | 5 | use defmt::{info, unwrap}; |
| 6 | use defmt_rtt as _; // global logger | ||
| 7 | use embassy::executor::Spawner; | 6 | use embassy::executor::Spawner; |
| 8 | use embassy::time::{Duration, Timer}; | 7 | use embassy::time::{Duration, Timer}; |
| 9 | use embassy_stm32::flash::Flash; | 8 | use embassy_stm32::flash::Flash; |
| 10 | use embassy_stm32::Peripherals; | 9 | use embassy_stm32::Peripherals; |
| 11 | use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; | 10 | use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; |
| 12 | use panic_probe as _; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 12 | ||
| 14 | #[embassy::main] | 13 | #[embassy::main] |
| 15 | async fn main(_spawner: Spawner, p: Peripherals) { | 14 | async fn main(_spawner: Spawner, p: Peripherals) { |
| @@ -39,8 +38,8 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 39 | unwrap!(f.write( | 38 | unwrap!(f.write( |
| 40 | ADDR, | 39 | ADDR, |
| 41 | &[ | 40 | &[ |
| 42 | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, | 41 | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, |
| 43 | 25, 26, 27, 28, 29, 30, 31, 32 | 42 | 30, 31, 32 |
| 44 | ] | 43 | ] |
| 45 | )); | 44 | )); |
| 46 | 45 | ||
| @@ -51,8 +50,8 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 51 | assert_eq!( | 50 | assert_eq!( |
| 52 | &buf[..], | 51 | &buf[..], |
| 53 | &[ | 52 | &[ |
| 54 | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, | 53 | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, |
| 55 | 25, 26, 27, 28, 29, 30, 31, 32 | 54 | 30, 31, 32 |
| 56 | ] | 55 | ] |
| 57 | ); | 56 | ); |
| 58 | } | 57 | } |
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 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use defmt_rtt as _; // global logger | ||
| 7 | use embassy::executor::Spawner; | 6 | use embassy::executor::Spawner; |
| 8 | use embassy::time::{Delay, Duration, Timer}; | 7 | use embassy::time::{Delay, Duration, Timer}; |
| 9 | use embassy_stm32::fmc::Fmc; | 8 | use embassy_stm32::fmc::Fmc; |
| 10 | use embassy_stm32::time::U32Ext; | 9 | use embassy_stm32::time::U32Ext; |
| 11 | use embassy_stm32::Config; | 10 | use embassy_stm32::{Config, Peripherals}; |
| 12 | use embassy_stm32::Peripherals; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | use panic_probe as _; | ||
| 14 | 12 | ||
| 15 | pub fn config() -> Config { | 13 | pub 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 | ||
diff --git a/examples/stm32h7/src/bin/low_level_timer_api.rs b/examples/stm32h7/src/bin/low_level_timer_api.rs index 647c5a8fa..3a728a0dd 100644 --- a/examples/stm32h7/src/bin/low_level_timer_api.rs +++ b/examples/stm32h7/src/bin/low_level_timer_api.rs | |||
| @@ -3,8 +3,6 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use core::marker::PhantomData; | 5 | use core::marker::PhantomData; |
| 6 | use defmt_rtt as _; // global logger | ||
| 7 | use panic_probe as _; | ||
| 8 | 6 | ||
| 9 | use defmt::*; | 7 | use defmt::*; |
| 10 | use embassy::executor::Spawner; | 8 | use embassy::executor::Spawner; |
| @@ -13,9 +11,8 @@ use embassy_stm32::gpio::low_level::AFType; | |||
| 13 | use embassy_stm32::gpio::Speed; | 11 | use embassy_stm32::gpio::Speed; |
| 14 | use embassy_stm32::pwm::*; | 12 | use embassy_stm32::pwm::*; |
| 15 | use embassy_stm32::time::{Hertz, U32Ext}; | 13 | use embassy_stm32::time::{Hertz, U32Ext}; |
| 16 | use embassy_stm32::unborrow; | 14 | use embassy_stm32::{unborrow, Config, Peripherals, Unborrow}; |
| 17 | use embassy_stm32::Unborrow; | 15 | use {defmt_rtt as _, panic_probe as _}; |
| 18 | use embassy_stm32::{Config, Peripherals}; | ||
| 19 | 16 | ||
| 20 | pub fn config() -> Config { | 17 | pub fn config() -> Config { |
| 21 | let mut config = Config::default(); | 18 | let mut config = Config::default(); |
| @@ -108,25 +105,18 @@ impl<'d, T: CaptureCompare32bitInstance> SimplePwm32<'d, T> { | |||
| 108 | 105 | ||
| 109 | pub fn enable(&mut self, channel: Channel) { | 106 | pub fn enable(&mut self, channel: Channel) { |
| 110 | unsafe { | 107 | unsafe { |
| 111 | T::regs_gp32() | 108 | T::regs_gp32().ccer().modify(|w| w.set_cce(channel.raw(), true)); |
| 112 | .ccer() | ||
| 113 | .modify(|w| w.set_cce(channel.raw(), true)); | ||
| 114 | } | 109 | } |
| 115 | } | 110 | } |
| 116 | 111 | ||
| 117 | pub fn disable(&mut self, channel: Channel) { | 112 | pub fn disable(&mut self, channel: Channel) { |
| 118 | unsafe { | 113 | unsafe { |
| 119 | T::regs_gp32() | 114 | T::regs_gp32().ccer().modify(|w| w.set_cce(channel.raw(), false)); |
| 120 | .ccer() | ||
| 121 | .modify(|w| w.set_cce(channel.raw(), false)); | ||
| 122 | } | 115 | } |
| 123 | } | 116 | } |
| 124 | 117 | ||
| 125 | pub fn set_freq<F: Into<Hertz>>(&mut self, freq: F) { | 118 | pub fn set_freq<F: Into<Hertz>>(&mut self, freq: F) { |
| 126 | <T as embassy_stm32::timer::low_level::GeneralPurpose32bitInstance>::set_frequency( | 119 | <T as embassy_stm32::timer::low_level::GeneralPurpose32bitInstance>::set_frequency(&mut self.inner, freq); |
| 127 | &mut self.inner, | ||
| 128 | freq, | ||
| 129 | ); | ||
| 130 | } | 120 | } |
| 131 | 121 | ||
| 132 | pub fn get_max_duty(&self) -> u32 { | 122 | pub fn get_max_duty(&self) -> u32 { |
| @@ -135,10 +125,6 @@ impl<'d, T: CaptureCompare32bitInstance> SimplePwm32<'d, T> { | |||
| 135 | 125 | ||
| 136 | pub fn set_duty(&mut self, channel: Channel, duty: u32) { | 126 | pub fn set_duty(&mut self, channel: Channel, duty: u32) { |
| 137 | defmt::assert!(duty < self.get_max_duty()); | 127 | defmt::assert!(duty < self.get_max_duty()); |
| 138 | unsafe { | 128 | unsafe { T::regs_gp32().ccr(channel.raw()).modify(|w| w.set_ccr(duty)) } |
| 139 | T::regs_gp32() | ||
| 140 | .ccr(channel.raw()) | ||
| 141 | .modify(|w| w.set_ccr(duty)) | ||
| 142 | } | ||
| 143 | } | 129 | } |
| 144 | } | 130 | } |
diff --git a/examples/stm32h7/src/bin/mco.rs b/examples/stm32h7/src/bin/mco.rs index a6735036f..6f03b5479 100644 --- a/examples/stm32h7/src/bin/mco.rs +++ b/examples/stm32h7/src/bin/mco.rs | |||
| @@ -3,13 +3,12 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use defmt_rtt as _; // global logger | ||
| 7 | use embassy::executor::Spawner; | 6 | use embassy::executor::Spawner; |
| 8 | use embassy::time::{Duration, Timer}; | 7 | use embassy::time::{Duration, Timer}; |
| 9 | use embassy_stm32::gpio::{Level, Output, Speed}; | 8 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 10 | use embassy_stm32::rcc::{Mco, Mco1Source, McoClock}; | 9 | use embassy_stm32::rcc::{Mco, Mco1Source, McoClock}; |
| 11 | use embassy_stm32::Peripherals; | 10 | use embassy_stm32::Peripherals; |
| 12 | use panic_probe as _; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 12 | ||
| 14 | #[embassy::main] | 13 | #[embassy::main] |
| 15 | async fn main(_spawner: Spawner, p: Peripherals) { | 14 | async fn main(_spawner: Spawner, p: Peripherals) { |
diff --git a/examples/stm32h7/src/bin/pwm.rs b/examples/stm32h7/src/bin/pwm.rs index c33ba066e..0e85b8d80 100644 --- a/examples/stm32h7/src/bin/pwm.rs +++ b/examples/stm32h7/src/bin/pwm.rs | |||
| @@ -3,13 +3,13 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use defmt_rtt as _; // global logger | ||
| 7 | use embassy::executor::Spawner; | 6 | use embassy::executor::Spawner; |
| 8 | use embassy::time::{Duration, Timer}; | 7 | use embassy::time::{Duration, Timer}; |
| 9 | use embassy_stm32::pwm::{simple_pwm::SimplePwm, Channel}; | 8 | use embassy_stm32::pwm::simple_pwm::SimplePwm; |
| 9 | use embassy_stm32::pwm::Channel; | ||
| 10 | use embassy_stm32::time::U32Ext; | 10 | use embassy_stm32::time::U32Ext; |
| 11 | use embassy_stm32::{Config, Peripherals}; | 11 | use embassy_stm32::{Config, Peripherals}; |
| 12 | use panic_probe as _; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| 14 | pub fn config() -> Config { | 14 | pub fn config() -> Config { |
| 15 | let mut config = Config::default(); | 15 | let mut config = Config::default(); |
diff --git a/examples/stm32h7/src/bin/rng.rs b/examples/stm32h7/src/bin/rng.rs index b914fa709..2b42a6afd 100644 --- a/examples/stm32h7/src/bin/rng.rs +++ b/examples/stm32h7/src/bin/rng.rs | |||
| @@ -3,11 +3,10 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use defmt_rtt as _; // global logger | ||
| 7 | use embassy::executor::Spawner; | 6 | use embassy::executor::Spawner; |
| 8 | use embassy_stm32::rng::Rng; | 7 | use embassy_stm32::rng::Rng; |
| 9 | use embassy_stm32::Peripherals; | 8 | use embassy_stm32::Peripherals; |
| 10 | use panic_probe as _; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy::main] | 11 | #[embassy::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner, p: Peripherals) { |
diff --git a/examples/stm32h7/src/bin/sdmmc.rs b/examples/stm32h7/src/bin/sdmmc.rs index c3b2ebcda..4a74780f4 100644 --- a/examples/stm32h7/src/bin/sdmmc.rs +++ b/examples/stm32h7/src/bin/sdmmc.rs | |||
| @@ -2,14 +2,12 @@ | |||
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt_rtt as _; // global logger | ||
| 6 | use panic_probe as _; | ||
| 7 | |||
| 8 | use defmt::*; | 5 | use defmt::*; |
| 9 | use embassy::executor::Spawner; | 6 | use embassy::executor::Spawner; |
| 10 | use embassy_stm32::sdmmc::Sdmmc; | 7 | use embassy_stm32::sdmmc::Sdmmc; |
| 11 | use embassy_stm32::time::U32Ext; | 8 | use embassy_stm32::time::U32Ext; |
| 12 | use embassy_stm32::{interrupt, Config, Peripherals}; | 9 | use embassy_stm32::{interrupt, Config, Peripherals}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | ||
| 13 | 11 | ||
| 14 | fn config() -> Config { | 12 | fn config() -> Config { |
| 15 | let mut config = Config::default(); | 13 | let mut config = Config::default(); |
diff --git a/examples/stm32h7/src/bin/signal.rs b/examples/stm32h7/src/bin/signal.rs index c63b2836c..f798b1c92 100644 --- a/examples/stm32h7/src/bin/signal.rs +++ b/examples/stm32h7/src/bin/signal.rs | |||
| @@ -2,17 +2,12 @@ | |||
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | // global logger | ||
| 6 | use defmt::{info, unwrap}; | 5 | use defmt::{info, unwrap}; |
| 7 | use defmt_rtt as _; | ||
| 8 | |||
| 9 | use panic_probe as _; | ||
| 10 | |||
| 11 | use embassy::channel::signal::Signal; | 6 | use embassy::channel::signal::Signal; |
| 12 | use embassy::executor::Spawner; | 7 | use embassy::executor::Spawner; |
| 13 | use embassy::time::{Duration, Timer}; | 8 | use embassy::time::{Duration, Timer}; |
| 14 | |||
| 15 | use embassy_stm32::Peripherals; | 9 | use embassy_stm32::Peripherals; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | ||
| 16 | 11 | ||
| 17 | static SIGNAL: Signal<u32> = Signal::new(); | 12 | static SIGNAL: Signal<u32> = Signal::new(); |
| 18 | 13 | ||
diff --git a/examples/stm32h7/src/bin/spi.rs b/examples/stm32h7/src/bin/spi.rs index a0acb03db..d4ee44292 100644 --- a/examples/stm32h7/src/bin/spi.rs +++ b/examples/stm32h7/src/bin/spi.rs | |||
| @@ -2,21 +2,19 @@ | |||
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt_rtt as _; // global logger | ||
| 6 | use panic_probe as _; | ||
| 7 | |||
| 8 | use core::fmt::Write; | 5 | use core::fmt::Write; |
| 9 | use core::str::from_utf8; | 6 | use core::str::from_utf8; |
| 7 | |||
| 10 | use cortex_m_rt::entry; | 8 | use cortex_m_rt::entry; |
| 11 | use defmt::*; | 9 | use defmt::*; |
| 12 | use embassy::executor::Executor; | 10 | use embassy::executor::Executor; |
| 13 | use embassy::util::Forever; | 11 | use embassy::util::Forever; |
| 14 | use embassy_stm32::dma::NoDma; | 12 | use embassy_stm32::dma::NoDma; |
| 15 | use embassy_stm32::peripherals::SPI3; | 13 | use embassy_stm32::peripherals::SPI3; |
| 16 | use embassy_stm32::spi; | ||
| 17 | use embassy_stm32::time::U32Ext; | 14 | use embassy_stm32::time::U32Ext; |
| 18 | use embassy_stm32::Config; | 15 | use embassy_stm32::{spi, Config}; |
| 19 | use heapless::String; | 16 | use heapless::String; |
| 17 | use {defmt_rtt as _, panic_probe as _}; | ||
| 20 | 18 | ||
| 21 | pub fn config() -> Config { | 19 | pub fn config() -> Config { |
| 22 | let mut config = Config::default(); | 20 | let mut config = Config::default(); |
diff --git a/examples/stm32h7/src/bin/spi_dma.rs b/examples/stm32h7/src/bin/spi_dma.rs index 8f77b1d09..003bc7add 100644 --- a/examples/stm32h7/src/bin/spi_dma.rs +++ b/examples/stm32h7/src/bin/spi_dma.rs | |||
| @@ -2,20 +2,18 @@ | |||
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt_rtt as _; // global logger | ||
| 6 | use panic_probe as _; | ||
| 7 | |||
| 8 | use core::fmt::Write; | 5 | use core::fmt::Write; |
| 9 | use core::str::from_utf8; | 6 | use core::str::from_utf8; |
| 7 | |||
| 10 | use cortex_m_rt::entry; | 8 | use cortex_m_rt::entry; |
| 11 | use defmt::*; | 9 | use defmt::*; |
| 12 | use embassy::executor::Executor; | 10 | use embassy::executor::Executor; |
| 13 | use embassy::util::Forever; | 11 | use embassy::util::Forever; |
| 14 | use embassy_stm32::peripherals::{DMA1_CH3, DMA1_CH4, SPI3}; | 12 | use embassy_stm32::peripherals::{DMA1_CH3, DMA1_CH4, SPI3}; |
| 15 | use embassy_stm32::spi; | ||
| 16 | use embassy_stm32::time::U32Ext; | 13 | use embassy_stm32::time::U32Ext; |
| 17 | use embassy_stm32::Config; | 14 | use embassy_stm32::{spi, Config}; |
| 18 | use heapless::String; | 15 | use heapless::String; |
| 16 | use {defmt_rtt as _, panic_probe as _}; | ||
| 19 | 17 | ||
| 20 | pub fn config() -> Config { | 18 | pub fn config() -> Config { |
| 21 | let mut config = Config::default(); | 19 | let mut config = Config::default(); |
diff --git a/examples/stm32h7/src/bin/usart.rs b/examples/stm32h7/src/bin/usart.rs index 0982a6ac6..fc3db5a33 100644 --- a/examples/stm32h7/src/bin/usart.rs +++ b/examples/stm32h7/src/bin/usart.rs | |||
| @@ -2,15 +2,13 @@ | |||
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use cortex_m_rt::entry; | ||
| 5 | use defmt::*; | 6 | use defmt::*; |
| 6 | use defmt_rtt as _; // global logger | ||
| 7 | use embassy::executor::Executor; | 7 | use embassy::executor::Executor; |
| 8 | use embassy::util::Forever; | 8 | use embassy::util::Forever; |
| 9 | use embassy_stm32::dma::NoDma; | 9 | use embassy_stm32::dma::NoDma; |
| 10 | use embassy_stm32::usart::{Config, Uart}; | 10 | use embassy_stm32::usart::{Config, Uart}; |
| 11 | use panic_probe as _; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | |||
| 13 | use cortex_m_rt::entry; | ||
| 14 | 12 | ||
| 15 | #[embassy::task] | 13 | #[embassy::task] |
| 16 | async fn main_task() { | 14 | async fn main_task() { |
diff --git a/examples/stm32h7/src/bin/usart_dma.rs b/examples/stm32h7/src/bin/usart_dma.rs index 74de8b2a3..d3325b0c1 100644 --- a/examples/stm32h7/src/bin/usart_dma.rs +++ b/examples/stm32h7/src/bin/usart_dma.rs | |||
| @@ -3,16 +3,15 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use core::fmt::Write; | 5 | use core::fmt::Write; |
| 6 | |||
| 7 | use cortex_m_rt::entry; | ||
| 6 | use defmt::*; | 8 | use defmt::*; |
| 7 | use defmt_rtt as _; // global logger | ||
| 8 | use embassy::executor::Executor; | 9 | use embassy::executor::Executor; |
| 9 | use embassy::util::Forever; | 10 | use embassy::util::Forever; |
| 10 | use embassy_stm32::dma::NoDma; | 11 | use embassy_stm32::dma::NoDma; |
| 11 | use embassy_stm32::usart::{Config, Uart}; | 12 | use embassy_stm32::usart::{Config, Uart}; |
| 12 | use panic_probe as _; | ||
| 13 | |||
| 14 | use cortex_m_rt::entry; | ||
| 15 | use heapless::String; | 13 | use heapless::String; |
| 14 | use {defmt_rtt as _, panic_probe as _}; | ||
| 16 | 15 | ||
| 17 | #[embassy::task] | 16 | #[embassy::task] |
| 18 | async fn main_task() { | 17 | async fn main_task() { |
diff --git a/examples/stm32h7/src/bin/usart_split.rs b/examples/stm32h7/src/bin/usart_split.rs index eb3f9578c..678d8c911 100644 --- a/examples/stm32h7/src/bin/usart_split.rs +++ b/examples/stm32h7/src/bin/usart_split.rs | |||
| @@ -3,17 +3,14 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use defmt_rtt as _; // global logger | ||
| 7 | use embassy::blocking_mutex::raw::ThreadModeRawMutex; | 6 | use embassy::blocking_mutex::raw::ThreadModeRawMutex; |
| 8 | use embassy::channel::mpmc::Channel; | 7 | use embassy::channel::mpmc::Channel; |
| 9 | use embassy::executor::Spawner; | 8 | use embassy::executor::Spawner; |
| 10 | use embassy_stm32::dma::NoDma; | 9 | use embassy_stm32::dma::NoDma; |
| 11 | use embassy_stm32::{ | 10 | use embassy_stm32::peripherals::{DMA1_CH1, UART7}; |
| 12 | peripherals::{DMA1_CH1, UART7}, | 11 | use embassy_stm32::usart::{Config, Uart, UartRx}; |
| 13 | usart::{Config, Uart, UartRx}, | 12 | use embassy_stm32::Peripherals; |
| 14 | Peripherals, | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 15 | }; | ||
| 16 | use panic_probe as _; | ||
| 17 | 14 | ||
| 18 | #[embassy::task] | 15 | #[embassy::task] |
| 19 | async fn writer(mut usart: Uart<'static, UART7, NoDma, NoDma>) { | 16 | async fn writer(mut usart: Uart<'static, UART7, NoDma, NoDma>) { |
