Run rustfmt.

This commit is contained in:
Dario Nieuwenhuis
2022-06-12 22:15:44 +02:00
parent 6199bdea71
commit a8703b7598
340 changed files with 1326 additions and 3020 deletions

View File

@ -2,16 +2,14 @@
#![no_main]
#![feature(type_alias_impl_trait)]
use defmt::*;
use embassy::executor::Spawner;
use embassy::time::{Delay, Duration, Timer};
use embassy_stm32::adc::{Adc, SampleTime};
use embassy_stm32::rcc::AdcClockSource;
use embassy_stm32::time::U32Ext;
use embassy_stm32::{Config, Peripherals};
use defmt::*;
use defmt_rtt as _; // global logger
use panic_probe as _;
use {defmt_rtt as _, panic_probe as _};
pub fn config() -> Config {
let mut config = Config::default();

View File

@ -3,12 +3,11 @@
#![feature(type_alias_impl_trait)]
use defmt::*;
use defmt_rtt as _; // global logger
use embassy::executor::Spawner;
use embassy::time::{Duration, Timer};
use embassy_stm32::gpio::{Level, Output, Speed};
use embassy_stm32::Peripherals;
use panic_probe as _;
use {defmt_rtt as _, panic_probe as _};
#[embassy::main]
async fn main(_spawner: Spawner, p: Peripherals) {

View File

@ -3,12 +3,11 @@
#![feature(type_alias_impl_trait)]
use defmt::*;
use defmt_rtt as _; // global logger
use embassy::executor::Spawner;
use embassy_stm32::exti::ExtiInput;
use embassy_stm32::gpio::{Input, Pull};
use embassy_stm32::Peripherals;
use panic_probe as _;
use {defmt_rtt as _, panic_probe as _};
#[embassy::main]
async fn main(_spawner: Spawner, p: Peripherals) {

View File

@ -7,14 +7,10 @@ use embassy::time::{Duration, Timer};
use embassy_stm32::dcmi::{self, *};
use embassy_stm32::gpio::{Level, Output, Speed};
use embassy_stm32::i2c::I2c;
use embassy_stm32::interrupt;
use embassy_stm32::rcc::{Mco, Mco1Source, McoClock};
use embassy_stm32::time::U32Ext;
use embassy_stm32::Config;
use embassy_stm32::Peripherals;
use defmt_rtt as _; // global logger
use panic_probe as _;
use embassy_stm32::{interrupt, Config, Peripherals};
use {defmt_rtt as _, panic_probe as _};
#[allow(unused)]
pub fn config() -> Config {
@ -43,15 +39,7 @@ async fn main(_spawner: Spawner, p: Peripherals) {
let mut led = Output::new(p.PE3, Level::High, Speed::Low);
let i2c_irq = interrupt::take!(I2C1_EV);
let cam_i2c = I2c::new(
p.I2C1,
p.PB8,
p.PB9,
i2c_irq,
p.DMA1_CH1,
p.DMA1_CH2,
100u32.khz(),
);
let cam_i2c = I2c::new(p.I2C1, p.PB8, p.PB9, i2c_irq, p.DMA1_CH1, p.DMA1_CH2, 100u32.khz());
let mut camera = Ov7725::new(cam_i2c, mco);
@ -60,17 +48,13 @@ async fn main(_spawner: Spawner, p: Peripherals) {
let manufacturer_id = defmt::unwrap!(camera.read_manufacturer_id().await);
let camera_id = defmt::unwrap!(camera.read_product_id().await);
defmt::info!(
"manufacturer: 0x{:x}, pid: 0x{:x}",
manufacturer_id,
camera_id
);
defmt::info!("manufacturer: 0x{:x}, pid: 0x{:x}", manufacturer_id, camera_id);
let dcmi_irq = interrupt::take!(DCMI);
let config = dcmi::Config::default();
let mut dcmi = Dcmi::new_8bit(
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, config,
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,
config,
);
defmt::info!("attempting capture");
@ -258,10 +242,8 @@ mod ov7725 {
let com3 = self.read(Register::Com3).await?;
let vflip = com3 & 0x80 > 0;
self.modify(Register::HRef, |reg| {
reg & 0xbf | if vflip { 0x40 } else { 0x40 }
})
.await?;
self.modify(Register::HRef, |reg| reg & 0xbf | if vflip { 0x40 } else { 0x40 })
.await?;
if horizontal <= 320 || vertical <= 240 {
self.write(Register::HStart, 0x3f).await?;
@ -291,11 +273,7 @@ mod ov7725 {
.map_err(Error::I2c)
}
async fn modify<F: FnOnce(u8) -> u8>(
&mut self,
register: Register,
f: F,
) -> Result<(), Error<Bus::Error>> {
async fn modify<F: FnOnce(u8) -> u8>(&mut self, register: Register, f: F) -> Result<(), Error<Bus::Error>> {
let value = self.read(register).await?;
let value = f(value);
self.write(register, value).await

View File

@ -2,14 +2,12 @@
#![no_main]
#![feature(type_alias_impl_trait)]
use defmt_rtt as _; // global logger
use panic_probe as _;
use cortex_m_rt::entry;
use defmt::*;
use embassy_stm32::dac::{Channel, Dac, Value};
use embassy_stm32::time::U32Ext;
use embassy_stm32::Config;
use {defmt_rtt as _, panic_probe as _};
pub fn config() -> Config {
let mut config = Config::default();

View File

@ -13,13 +13,10 @@ use embassy_stm32::eth::{Ethernet, State};
use embassy_stm32::peripherals::ETH;
use embassy_stm32::rng::Rng;
use embassy_stm32::time::U32Ext;
use embassy_stm32::Config;
use embassy_stm32::{interrupt, Peripherals};
use embassy_stm32::{interrupt, Config, Peripherals};
use embedded_io::asynch::Write;
use defmt_rtt as _; // global logger
use panic_probe as _;
use rand_core::RngCore;
use {defmt_rtt as _, panic_probe as _};
macro_rules! forever {
($val:expr) => {{

View File

@ -3,13 +3,12 @@
#![feature(type_alias_impl_trait)]
use defmt::{info, unwrap};
use defmt_rtt as _; // global logger
use embassy::executor::Spawner;
use embassy::time::{Duration, Timer};
use embassy_stm32::flash::Flash;
use embassy_stm32::Peripherals;
use embedded_storage::nor_flash::{NorFlash, ReadNorFlash};
use panic_probe as _;
use {defmt_rtt as _, panic_probe as _};
#[embassy::main]
async fn main(_spawner: Spawner, p: Peripherals) {
@ -39,8 +38,8 @@ async fn main(_spawner: Spawner, p: Peripherals) {
unwrap!(f.write(
ADDR,
&[
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, 30, 31, 32
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,
30, 31, 32
]
));
@ -51,8 +50,8 @@ async fn main(_spawner: Spawner, p: Peripherals) {
assert_eq!(
&buf[..],
&[
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, 30, 31, 32
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,
30, 31, 32
]
);
}

View File

@ -3,14 +3,12 @@
#![feature(type_alias_impl_trait)]
use defmt::*;
use defmt_rtt as _; // global logger
use embassy::executor::Spawner;
use embassy::time::{Delay, Duration, Timer};
use embassy_stm32::fmc::Fmc;
use embassy_stm32::time::U32Ext;
use embassy_stm32::Config;
use embassy_stm32::Peripherals;
use panic_probe as _;
use embassy_stm32::{Config, Peripherals};
use {defmt_rtt as _, panic_probe as _};
pub fn config() -> Config {
let mut config = Config::default();
@ -62,16 +60,8 @@ async fn main(_spawner: Spawner, p: Peripherals) {
const REGION_WRITE_BACK: u32 = 0x01;
const REGION_ENABLE: u32 = 0x01;
crate::assert_eq!(
size & (size - 1),
0,
"SDRAM memory region size must be a power of 2"
);
crate::assert_eq!(
size & 0x1F,
0,
"SDRAM memory region size must be 32 bytes or more"
);
crate::assert_eq!(size & (size - 1), 0, "SDRAM memory region size must be a power of 2");
crate::assert_eq!(size & 0x1F, 0, "SDRAM memory region size must be 32 bytes or more");
fn log2minus1(sz: u32) -> u32 {
for i in 5..=31 {
if sz == (1 << i) {
@ -104,8 +94,7 @@ async fn main(_spawner: Spawner, p: Peripherals) {
// Enable
unsafe {
mpu.ctrl
.modify(|r| r | MPU_DEFAULT_MMAP_FOR_PRIVILEGED | MPU_ENABLE);
mpu.ctrl.modify(|r| r | MPU_DEFAULT_MMAP_FOR_PRIVILEGED | MPU_ENABLE);
scb.shcsr.modify(|r| r | MEMFAULTENA);

View File

@ -3,8 +3,6 @@
#![feature(type_alias_impl_trait)]
use core::marker::PhantomData;
use defmt_rtt as _; // global logger
use panic_probe as _;
use defmt::*;
use embassy::executor::Spawner;
@ -13,9 +11,8 @@ use embassy_stm32::gpio::low_level::AFType;
use embassy_stm32::gpio::Speed;
use embassy_stm32::pwm::*;
use embassy_stm32::time::{Hertz, U32Ext};
use embassy_stm32::unborrow;
use embassy_stm32::Unborrow;
use embassy_stm32::{Config, Peripherals};
use embassy_stm32::{unborrow, Config, Peripherals, Unborrow};
use {defmt_rtt as _, panic_probe as _};
pub fn config() -> Config {
let mut config = Config::default();
@ -108,25 +105,18 @@ impl<'d, T: CaptureCompare32bitInstance> SimplePwm32<'d, T> {
pub fn enable(&mut self, channel: Channel) {
unsafe {
T::regs_gp32()
.ccer()
.modify(|w| w.set_cce(channel.raw(), true));
T::regs_gp32().ccer().modify(|w| w.set_cce(channel.raw(), true));
}
}
pub fn disable(&mut self, channel: Channel) {
unsafe {
T::regs_gp32()
.ccer()
.modify(|w| w.set_cce(channel.raw(), false));
T::regs_gp32().ccer().modify(|w| w.set_cce(channel.raw(), false));
}
}
pub fn set_freq<F: Into<Hertz>>(&mut self, freq: F) {
<T as embassy_stm32::timer::low_level::GeneralPurpose32bitInstance>::set_frequency(
&mut self.inner,
freq,
);
<T as embassy_stm32::timer::low_level::GeneralPurpose32bitInstance>::set_frequency(&mut self.inner, freq);
}
pub fn get_max_duty(&self) -> u32 {
@ -135,10 +125,6 @@ impl<'d, T: CaptureCompare32bitInstance> SimplePwm32<'d, T> {
pub fn set_duty(&mut self, channel: Channel, duty: u32) {
defmt::assert!(duty < self.get_max_duty());
unsafe {
T::regs_gp32()
.ccr(channel.raw())
.modify(|w| w.set_ccr(duty))
}
unsafe { T::regs_gp32().ccr(channel.raw()).modify(|w| w.set_ccr(duty)) }
}
}

View File

@ -3,13 +3,12 @@
#![feature(type_alias_impl_trait)]
use defmt::*;
use defmt_rtt as _; // global logger
use embassy::executor::Spawner;
use embassy::time::{Duration, Timer};
use embassy_stm32::gpio::{Level, Output, Speed};
use embassy_stm32::rcc::{Mco, Mco1Source, McoClock};
use embassy_stm32::Peripherals;
use panic_probe as _;
use {defmt_rtt as _, panic_probe as _};
#[embassy::main]
async fn main(_spawner: Spawner, p: Peripherals) {

View File

@ -3,13 +3,13 @@
#![feature(type_alias_impl_trait)]
use defmt::*;
use defmt_rtt as _; // global logger
use embassy::executor::Spawner;
use embassy::time::{Duration, Timer};
use embassy_stm32::pwm::{simple_pwm::SimplePwm, Channel};
use embassy_stm32::pwm::simple_pwm::SimplePwm;
use embassy_stm32::pwm::Channel;
use embassy_stm32::time::U32Ext;
use embassy_stm32::{Config, Peripherals};
use panic_probe as _;
use {defmt_rtt as _, panic_probe as _};
pub fn config() -> Config {
let mut config = Config::default();

View File

@ -3,11 +3,10 @@
#![feature(type_alias_impl_trait)]
use defmt::*;
use defmt_rtt as _; // global logger
use embassy::executor::Spawner;
use embassy_stm32::rng::Rng;
use embassy_stm32::Peripherals;
use panic_probe as _;
use {defmt_rtt as _, panic_probe as _};
#[embassy::main]
async fn main(_spawner: Spawner, p: Peripherals) {

View File

@ -2,14 +2,12 @@
#![no_main]
#![feature(type_alias_impl_trait)]
use defmt_rtt as _; // global logger
use panic_probe as _;
use defmt::*;
use embassy::executor::Spawner;
use embassy_stm32::sdmmc::Sdmmc;
use embassy_stm32::time::U32Ext;
use embassy_stm32::{interrupt, Config, Peripherals};
use {defmt_rtt as _, panic_probe as _};
fn config() -> Config {
let mut config = Config::default();

View File

@ -2,17 +2,12 @@
#![no_main]
#![feature(type_alias_impl_trait)]
// global logger
use defmt::{info, unwrap};
use defmt_rtt as _;
use panic_probe as _;
use embassy::channel::signal::Signal;
use embassy::executor::Spawner;
use embassy::time::{Duration, Timer};
use embassy_stm32::Peripherals;
use {defmt_rtt as _, panic_probe as _};
static SIGNAL: Signal<u32> = Signal::new();

View File

@ -2,21 +2,19 @@
#![no_main]
#![feature(type_alias_impl_trait)]
use defmt_rtt as _; // global logger
use panic_probe as _;
use core::fmt::Write;
use core::str::from_utf8;
use cortex_m_rt::entry;
use defmt::*;
use embassy::executor::Executor;
use embassy::util::Forever;
use embassy_stm32::dma::NoDma;
use embassy_stm32::peripherals::SPI3;
use embassy_stm32::spi;
use embassy_stm32::time::U32Ext;
use embassy_stm32::Config;
use embassy_stm32::{spi, Config};
use heapless::String;
use {defmt_rtt as _, panic_probe as _};
pub fn config() -> Config {
let mut config = Config::default();

View File

@ -2,20 +2,18 @@
#![no_main]
#![feature(type_alias_impl_trait)]
use defmt_rtt as _; // global logger
use panic_probe as _;
use core::fmt::Write;
use core::str::from_utf8;
use cortex_m_rt::entry;
use defmt::*;
use embassy::executor::Executor;
use embassy::util::Forever;
use embassy_stm32::peripherals::{DMA1_CH3, DMA1_CH4, SPI3};
use embassy_stm32::spi;
use embassy_stm32::time::U32Ext;
use embassy_stm32::Config;
use embassy_stm32::{spi, Config};
use heapless::String;
use {defmt_rtt as _, panic_probe as _};
pub fn config() -> Config {
let mut config = Config::default();

View File

@ -2,15 +2,13 @@
#![no_main]
#![feature(type_alias_impl_trait)]
use cortex_m_rt::entry;
use defmt::*;
use defmt_rtt as _; // global logger
use embassy::executor::Executor;
use embassy::util::Forever;
use embassy_stm32::dma::NoDma;
use embassy_stm32::usart::{Config, Uart};
use panic_probe as _;
use cortex_m_rt::entry;
use {defmt_rtt as _, panic_probe as _};
#[embassy::task]
async fn main_task() {

View File

@ -3,16 +3,15 @@
#![feature(type_alias_impl_trait)]
use core::fmt::Write;
use cortex_m_rt::entry;
use defmt::*;
use defmt_rtt as _; // global logger
use embassy::executor::Executor;
use embassy::util::Forever;
use embassy_stm32::dma::NoDma;
use embassy_stm32::usart::{Config, Uart};
use panic_probe as _;
use cortex_m_rt::entry;
use heapless::String;
use {defmt_rtt as _, panic_probe as _};
#[embassy::task]
async fn main_task() {

View File

@ -3,17 +3,14 @@
#![feature(type_alias_impl_trait)]
use defmt::*;
use defmt_rtt as _; // global logger
use embassy::blocking_mutex::raw::ThreadModeRawMutex;
use embassy::channel::mpmc::Channel;
use embassy::executor::Spawner;
use embassy_stm32::dma::NoDma;
use embassy_stm32::{
peripherals::{DMA1_CH1, UART7},
usart::{Config, Uart, UartRx},
Peripherals,
};
use panic_probe as _;
use embassy_stm32::peripherals::{DMA1_CH1, UART7};
use embassy_stm32::usart::{Config, Uart, UartRx};
use embassy_stm32::Peripherals;
use {defmt_rtt as _, panic_probe as _};
#[embassy::task]
async fn writer(mut usart: Uart<'static, UART7, NoDma, NoDma>) {