Skip to content

Commit

Permalink
Reformat with use_small_heuristics = "Max"
Browse files Browse the repository at this point in the history
  • Loading branch information
valff committed Dec 24, 2019
1 parent 2676ed2 commit ea92699
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 50 deletions.
2 changes: 2 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ format_strings = true
merge_imports = true
newline_style = "Unix"
overflow_delimited_expr = true
reorder_impl_items = true
unstable_features = true
use_field_init_shorthand = true
use_small_heuristics = "Max"
version = "Two"
12 changes: 2 additions & 10 deletions src/periph/gpio/head.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,7 @@ map_gpio_port_head! {
IOPESMEN,
}

#[cfg(any(
stm32_mcu = "stm32f100",
stm32_mcu = "stm32f101",
stm32_mcu = "stm32f103"
))]
#[cfg(any(stm32_mcu = "stm32f100", stm32_mcu = "stm32f101", stm32_mcu = "stm32f103"))]
map_gpio_port_head! {
"Extracts GPIO port F head register tokens.",
periph_gpio_f_head,
Expand All @@ -257,11 +253,7 @@ map_gpio_port_head! {
IOPFSMEN,
}

#[cfg(any(
stm32_mcu = "stm32f100",
stm32_mcu = "stm32f101",
stm32_mcu = "stm32f103"
))]
#[cfg(any(stm32_mcu = "stm32f100", stm32_mcu = "stm32f101", stm32_mcu = "stm32f103"))]
map_gpio_port_head! {
"Extracts GPIO port G head register tokens.",
periph_gpio_g_head,
Expand Down
12 changes: 2 additions & 10 deletions src/periph/gpio/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1134,11 +1134,7 @@ map_gpio_port! {
(),
}

#[cfg(any(
stm32_mcu = "stm32f100",
stm32_mcu = "stm32f101",
stm32_mcu = "stm32f103"
))]
#[cfg(any(stm32_mcu = "stm32f100", stm32_mcu = "stm32f101", stm32_mcu = "stm32f103"))]
map_gpio_port! {
"Extracts GPIO port F register tokens.",
periph_gpio_f,
Expand All @@ -1154,11 +1150,7 @@ map_gpio_port! {
(),
}

#[cfg(any(
stm32_mcu = "stm32f100",
stm32_mcu = "stm32f101",
stm32_mcu = "stm32f103"
))]
#[cfg(any(stm32_mcu = "stm32f100", stm32_mcu = "stm32f101", stm32_mcu = "stm32f103"))]
map_gpio_port! {
"Extracts GPIO port G register tokens.",
periph_gpio_g,
Expand Down
6 changes: 2 additions & 4 deletions svd/src/adc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ pub fn fix_adc1_1(dev: &mut Device) -> Result<()> {
pub fn fix_adc_1(dev: &mut Device) -> Result<()> {
dev.periph("ADC").reg("SMPR1").remove_field("SMPPLUS");
for i in 1..=4 {
dev.periph("ADC")
.reg(&format!("JDR{}", i))
.field(&format!("JDATA{}", i))
.name = "JDATA".to_string();
dev.periph("ADC").reg(&format!("JDR{}", i)).field(&format!("JDATA{}", i)).name =
"JDATA".to_string();
}
Ok(())
}
Expand Down
24 changes: 3 additions & 21 deletions svd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,7 @@ pub use anyhow::{bail, Result};
use drone_svd::Device;
use std::{env, fs::File, path::Path};

const REG_EXCLUDE: &[&str] = &[
"FPU",
"FPU_CPACR",
"ITM",
"MPU",
"NVIC",
"SCB",
"STK",
"TPIU",
];
const REG_EXCLUDE: &[&str] = &["FPU", "FPU_CPACR", "ITM", "MPU", "NVIC", "SCB", "STK", "TPIU"];

/// Generates code for register mappings.
pub fn generate_regs(pool_number: usize, pool_size: usize) -> Result<()> {
Expand All @@ -50,12 +41,7 @@ pub fn generate_rest() -> Result<()> {
let dev = svd_deserialize()?;
let mut reg_tokens = File::create(out_dir.join("svd_reg_index.rs"))?;
let mut interrupts = File::create(out_dir.join("svd_interrupts.rs"))?;
dev.generate_rest(
&mut reg_tokens,
&mut interrupts,
REG_EXCLUDE,
"stm32_reg_tokens",
)
dev.generate_rest(&mut reg_tokens, &mut interrupts, REG_EXCLUDE, "stm32_reg_tokens")
}

fn svd_deserialize() -> Result<Device> {
Expand Down Expand Up @@ -422,11 +408,7 @@ fn copy_field(
reg_name: &str,
field_name: &str,
) {
let field = dev
.periph(periph_from)
.reg(reg_name)
.field(field_name)
.clone();
let field = dev.periph(periph_from).reg(reg_name).field(field_name).clone();
dev.periph(periph_to).reg(reg_name).add_field(field);
}

Expand Down
8 changes: 3 additions & 5 deletions svd/src/rcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,9 @@ pub fn fix_2(dev: &mut Device) -> Result<()> {
}

pub fn fix_3(dev: &mut Device) -> Result<()> {
for (reg_name, field_name) in &[
("AHB1ENR", "GPIOIEN"),
("AHB1RSTR", "GPIOIRST"),
("AHB1LPENR", "GPIOILPEN"),
] {
for (reg_name, field_name) in
&[("AHB1ENR", "GPIOIEN"), ("AHB1RSTR", "GPIOIRST"), ("AHB1LPENR", "GPIOILPEN")]
{
for (name, description, offset) in &[("GPIOJ", "port J", 1), ("GPIOK", "port K", 2)] {
let mut field = dev.periph("RCC").reg(reg_name).field(field_name).clone();
field.name = field.name.replace("GPIOI", name);
Expand Down

0 comments on commit ea92699

Please sign in to comment.