From 95aadbbe18211db3154fbda182aa1f7c3e880ebd Mon Sep 17 00:00:00 2001 From: Jesse Braham Date: Sun, 13 Jan 2019 18:37:47 -0800 Subject: [PATCH 1/7] Add support for stm32f038 --- Cargo.toml | 1 + src/adc.rs | 3 +++ src/gpio.rs | 24 ++++++++++++++++-------- src/i2c.rs | 8 +++++++- src/lib.rs | 3 +++ src/serial.rs | 3 ++- src/spi.rs | 2 +- src/timers.rs | 1 + 8 files changed, 34 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6786b8f..fe1e1be 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,6 +55,7 @@ stm32f030x6 = ["stm32f030"] stm32f030x8 = ["stm32f030"] stm32f030xc = ["stm32f030"] stm32f031 = ["stm32f0/stm32f0x1", "device-selected"] +stm32f038 = ["stm32f0/stm32f0x8", "device-selected"] stm32f042 = ["stm32f0/stm32f0x2", "device-selected"] stm32f051 = ["stm32f0/stm32f0x1", "device-selected"] stm32f070 = ["stm32f0/stm32f0x0", "device-selected"] diff --git a/src/adc.rs b/src/adc.rs index 63246e7..fb3fcaf 100644 --- a/src/adc.rs +++ b/src/adc.rs @@ -354,6 +354,7 @@ impl VRef { #[cfg(any( feature = "stm32f031", + feature = "stm32f038", feature = "stm32f042", feature = "stm32f051", feature = "stm32f071", @@ -366,6 +367,7 @@ pub struct VBat; #[cfg(any( feature = "stm32f031", + feature = "stm32f038", feature = "stm32f042", feature = "stm32f051", feature = "stm32f071", @@ -378,6 +380,7 @@ adc_pins!( #[cfg(any( feature = "stm32f031", + feature = "stm32f038", feature = "stm32f042", feature = "stm32f051", feature = "stm32f071", diff --git a/src/gpio.rs b/src/gpio.rs index 6d7be1d..1c1100f 100644 --- a/src/gpio.rs +++ b/src/gpio.rs @@ -561,7 +561,7 @@ gpio!(GPIOB, gpiob, iopben, PB, [ PB15: (pb15, 15, Input), ]); -#[cfg(feature = "stm32f042")] +#[cfg(any(feature = "stm32f038", feature = "stm32f042"))] gpio!(GPIOC, gpioc, iopcen, PC, [ PC13: (pc13, 13, Input), PC14: (pc14, 14, Input), @@ -643,13 +643,6 @@ gpio!(GPIOD, gpiod, iopden, PD, [ // PE15: (pe15, 15, Input), // ]); -#[cfg(feature = "stm32f042")] -gpio!(GPIOF, gpiof, iopfen, PF, [ - PF0: (pf0, 0, Input), - PF1: (pf1, 1, Input), - PF11: (pf11, 11, Input), -]); - #[cfg(any(feature = "stm32f030", feature = "stm32f051"))] gpio!(GPIOF, gpiof, iopfen, PF, [ PF0: (pf0, 0, Input), @@ -666,6 +659,21 @@ gpio!(GPIOF, gpiof, iopfen, PF, [ PF7: (pf7, 7, Input), ]); +#[cfg(feature = "stm32f038")] +gpio!(GPIOF, gpiof, iopfen, PF, [ + PF0: (pf0, 0, Input), + PF1: (pf1, 1, Input), + PF6: (pf6, 6, Input), + PF7: (pf7, 7, Input), +]); + +#[cfg(feature = "stm32f042")] +gpio!(GPIOF, gpiof, iopfen, PF, [ + PF0: (pf0, 0, Input), + PF1: (pf1, 1, Input), + PF11: (pf11, 11, Input), +]); + #[cfg(feature = "stm32f070")] gpio!(GPIOF, gpiof, iopfen, PF, [ PF0: (pf0, 0, Input), diff --git a/src/i2c.rs b/src/i2c.rs index a56fe97..f4c74f5 100644 --- a/src/i2c.rs +++ b/src/i2c.rs @@ -36,6 +36,7 @@ macro_rules! i2c_pins { #[cfg(any( feature = "stm32f030", feature = "stm32f031", + feature = "stm32f038", feature = "stm32f042", feature = "stm32f051", feature = "stm32f070", @@ -69,7 +70,12 @@ i2c_pins! { sda => [gpioa::PA12>], } } -#[cfg(any(feature = "stm32f031", feature = "stm32f042", feature = "stm32f030x6"))] +#[cfg(any( + feature = "stm32f031", + feature = "stm32f038", + feature = "stm32f042", + feature = "stm32f030x6", +))] i2c_pins! { I2C1 => { scl => [gpiob::PB10>], diff --git a/src/lib.rs b/src/lib.rs index cf36be8..01f5c83 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,6 +17,9 @@ pub use stm32f0::stm32f0x1 as stm32; #[cfg(any(feature = "stm32f042", feature = "stm32f072"))] pub use stm32f0::stm32f0x2 as stm32; +#[cfg(feature = "stm32f038")] +pub use stm32f0::stm32f0x8 as stm32; + #[cfg(feature = "device-selected")] pub mod adc; #[cfg(feature = "device-selected")] diff --git a/src/serial.rs b/src/serial.rs index 7c620e9..fba9eb9 100644 --- a/src/serial.rs +++ b/src/serial.rs @@ -126,7 +126,7 @@ usart_pins! { rx => [gpioa::PA10>, gpiob::PB6>], } } -#[cfg(any(feature = "stm32f031", feature = "stm32f030x6"))] +#[cfg(any(feature = "stm32f030x6", feature = "stm32f031", feature = "stm32f038"))] usart_pins! { USART1 => { tx => [gpioa::PA2>, gpioa::PA14>], @@ -135,6 +135,7 @@ usart_pins! { } #[cfg(any( feature = "stm32f031", + feature = "stm32f038", feature = "stm32f070", feature = "stm32f072", feature = "stm32f091", diff --git a/src/spi.rs b/src/spi.rs index 7818871..00f9dbe 100644 --- a/src/spi.rs +++ b/src/spi.rs @@ -112,7 +112,7 @@ spi_pins! { mosi => [gpioa::PA7>, gpiob::PB5>], } } -#[cfg(feature = "stm32f030x6")] +#[cfg(any(feature = "stm32f030x6", feature = "stm32f038"))] spi_pins! { SPI1 => { sck => [gpiob::PB13>], diff --git a/src/timers.rs b/src/timers.rs index 08e8018..e78add0 100644 --- a/src/timers.rs +++ b/src/timers.rs @@ -224,6 +224,7 @@ timers! { #[cfg(any( feature = "stm32f031", + feature = "stm32f038", feature = "stm32f042", feature = "stm32f051", feature = "stm32f071", From e225bc0f68c7013b8feb1f9d59d5645e04a18fa6 Mon Sep 17 00:00:00 2001 From: Jesse Braham Date: Sun, 13 Jan 2019 19:11:23 -0800 Subject: [PATCH 2/7] Add support for stm32f048 --- Cargo.toml | 1 + src/adc.rs | 3 +++ src/gpio.rs | 4 ++-- src/i2c.rs | 16 +++++++++++++--- src/lib.rs | 2 +- src/serial.rs | 3 +++ src/spi.rs | 3 +++ src/timers.rs | 1 + 8 files changed, 27 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index fe1e1be..53df9cd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -57,6 +57,7 @@ stm32f030xc = ["stm32f030"] stm32f031 = ["stm32f0/stm32f0x1", "device-selected"] stm32f038 = ["stm32f0/stm32f0x8", "device-selected"] stm32f042 = ["stm32f0/stm32f0x2", "device-selected"] +stm32f048 = ["stm32f0/stm32f0x8", "device-selected"] stm32f051 = ["stm32f0/stm32f0x1", "device-selected"] stm32f070 = ["stm32f0/stm32f0x0", "device-selected"] stm32f070x6 = ["stm32f070"] diff --git a/src/adc.rs b/src/adc.rs index fb3fcaf..4a7ee49 100644 --- a/src/adc.rs +++ b/src/adc.rs @@ -356,6 +356,7 @@ impl VRef { feature = "stm32f031", feature = "stm32f038", feature = "stm32f042", + feature = "stm32f048", feature = "stm32f051", feature = "stm32f071", feature = "stm32f072", @@ -369,6 +370,7 @@ pub struct VBat; feature = "stm32f031", feature = "stm32f038", feature = "stm32f042", + feature = "stm32f048", feature = "stm32f051", feature = "stm32f071", feature = "stm32f072", @@ -382,6 +384,7 @@ adc_pins!( feature = "stm32f031", feature = "stm32f038", feature = "stm32f042", + feature = "stm32f048", feature = "stm32f051", feature = "stm32f071", feature = "stm32f072", diff --git a/src/gpio.rs b/src/gpio.rs index 1c1100f..6ab9e15 100644 --- a/src/gpio.rs +++ b/src/gpio.rs @@ -561,7 +561,7 @@ gpio!(GPIOB, gpiob, iopben, PB, [ PB15: (pb15, 15, Input), ]); -#[cfg(any(feature = "stm32f038", feature = "stm32f042"))] +#[cfg(any(feature = "stm32f038", feature = "stm32f042", feature = "stm32f048"))] gpio!(GPIOC, gpioc, iopcen, PC, [ PC13: (pc13, 13, Input), PC14: (pc14, 14, Input), @@ -667,7 +667,7 @@ gpio!(GPIOF, gpiof, iopfen, PF, [ PF7: (pf7, 7, Input), ]); -#[cfg(feature = "stm32f042")] +#[cfg(any(feature = "stm32f042", feature = "stm32f048"))] gpio!(GPIOF, gpiof, iopfen, PF, [ PF0: (pf0, 0, Input), PF1: (pf1, 1, Input), diff --git a/src/i2c.rs b/src/i2c.rs index f4c74f5..587723a 100644 --- a/src/i2c.rs +++ b/src/i2c.rs @@ -38,6 +38,7 @@ macro_rules! i2c_pins { feature = "stm32f031", feature = "stm32f038", feature = "stm32f042", + feature = "stm32f048", feature = "stm32f051", feature = "stm32f070", feature = "stm32f071", @@ -55,6 +56,7 @@ i2c_pins! { feature = "stm32f030xc", feature = "stm32f031", feature = "stm32f042", + feature = "stm32f048", feature = "stm32f091", ))] i2c_pins! { @@ -63,7 +65,7 @@ i2c_pins! { sda => [gpioa::PA10>], } } -#[cfg(any(feature = "stm32f030", feature = "stm32f042"))] +#[cfg(any(feature = "stm32f030", feature = "stm32f042", feature = "stm32f048"))] i2c_pins! { I2C1 => { scl => [gpioa::PA11>], @@ -74,6 +76,7 @@ i2c_pins! { feature = "stm32f031", feature = "stm32f038", feature = "stm32f042", + feature = "stm32f048", feature = "stm32f030x6", ))] i2c_pins! { @@ -82,11 +85,18 @@ i2c_pins! { sda => [gpiob::PB11>], } } +#[cfg(any(feature = "stm32f030xc", feature = "stm32f042", feature = "stm32f048"))] +i2c_pins! { + I2C1 => { + scl => [gpiob::PB13>], + sda => [gpiob::PB14>], + } +} #[cfg(any(feature = "stm32f042", feature = "stm32f030xc"))] i2c_pins! { I2C1 => { - scl => [gpiob::PB13>, gpiof::PF1>], - sda => [gpiob::PB14>, gpiof::PF0>], + scl => [gpiof::PF1>], + sda => [gpiof::PF0>], } } #[cfg(feature = "stm32f070x6")] diff --git a/src/lib.rs b/src/lib.rs index 01f5c83..a46f8c0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,7 +17,7 @@ pub use stm32f0::stm32f0x1 as stm32; #[cfg(any(feature = "stm32f042", feature = "stm32f072"))] pub use stm32f0::stm32f0x2 as stm32; -#[cfg(feature = "stm32f038")] +#[cfg(any(feature = "stm32f038", feature = "stm32f048"))] pub use stm32f0::stm32f0x8 as stm32; #[cfg(feature = "device-selected")] diff --git a/src/serial.rs b/src/serial.rs index fba9eb9..0d657f2 100644 --- a/src/serial.rs +++ b/src/serial.rs @@ -117,6 +117,7 @@ macro_rules! usart_pins { #[cfg(any( feature = "stm32f030", feature = "stm32f042", + feature = "stm32f048", feature = "stm32f051", feature = "stm32f071", ))] @@ -151,6 +152,7 @@ usart_pins! { feature = "stm32f030x8", feature = "stm32f030xc", feature = "stm32f042", + feature = "stm32f048", feature = "stm32f051", feature = "stm32f070", feature = "stm32f071", @@ -366,6 +368,7 @@ usart! { feature = "stm32f030x8", feature = "stm32f030xc", feature = "stm32f042", + feature = "stm32f048", feature = "stm32f051", feature = "stm32f070", feature = "stm32f071", diff --git a/src/spi.rs b/src/spi.rs index 00f9dbe..532a361 100644 --- a/src/spi.rs +++ b/src/spi.rs @@ -49,6 +49,7 @@ use crate::stm32::SPI1; #[cfg(any( feature = "stm32f030x8", feature = "stm32f030xc", + feature = "stm32f048", feature = "stm32f051", feature = "stm32f070xb", feature = "stm32f071", @@ -135,6 +136,7 @@ spi_pins! { #[cfg(any( feature = "stm32f030x8", feature = "stm32f030xc", + feature = "stm32f048", feature = "stm32f051", feature = "stm32f070xb", feature = "stm32f071", @@ -209,6 +211,7 @@ spi! { #[cfg(any( feature = "stm32f030x8", feature = "stm32f030xc", + feature = "stm32f048", feature = "stm32f051", feature = "stm32f070xb", feature = "stm32f071", diff --git a/src/timers.rs b/src/timers.rs index e78add0..2bbe6f7 100644 --- a/src/timers.rs +++ b/src/timers.rs @@ -226,6 +226,7 @@ timers! { feature = "stm32f031", feature = "stm32f038", feature = "stm32f042", + feature = "stm32f048", feature = "stm32f051", feature = "stm32f071", feature = "stm32f072", From c79c69c0f36bef903c6e33ceed1f1fc0be52db98 Mon Sep 17 00:00:00 2001 From: Jesse Braham Date: Sun, 13 Jan 2019 20:16:16 -0800 Subject: [PATCH 3/7] Add support for stm32f058 --- Cargo.toml | 1 + src/adc.rs | 4 ++++ src/gpio.rs | 12 ++++++++---- src/i2c.rs | 4 +++- src/lib.rs | 2 +- src/serial.rs | 3 +++ src/spi.rs | 3 +++ src/timers.rs | 2 ++ 8 files changed, 25 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 53df9cd..44c2ce9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,6 +59,7 @@ stm32f038 = ["stm32f0/stm32f0x8", "device-selected"] stm32f042 = ["stm32f0/stm32f0x2", "device-selected"] stm32f048 = ["stm32f0/stm32f0x8", "device-selected"] stm32f051 = ["stm32f0/stm32f0x1", "device-selected"] +stm32f058 = ["stm32f0/stm32f0x8", "device-selected"] stm32f070 = ["stm32f0/stm32f0x0", "device-selected"] stm32f070x6 = ["stm32f070"] stm32f070xb = ["stm32f070"] diff --git a/src/adc.rs b/src/adc.rs index 4a7ee49..1d155d7 100644 --- a/src/adc.rs +++ b/src/adc.rs @@ -207,6 +207,7 @@ adc_pins!( #[cfg(any( feature = "stm32f030", feature = "stm32f051", + feature = "stm32f058", feature = "stm32f070", feature = "stm32f071", feature = "stm32f072", @@ -358,6 +359,7 @@ impl VRef { feature = "stm32f042", feature = "stm32f048", feature = "stm32f051", + feature = "stm32f058", feature = "stm32f071", feature = "stm32f072", feature = "stm32f091", @@ -372,6 +374,7 @@ pub struct VBat; feature = "stm32f042", feature = "stm32f048", feature = "stm32f051", + feature = "stm32f058", feature = "stm32f071", feature = "stm32f072", feature = "stm32f091", @@ -386,6 +389,7 @@ adc_pins!( feature = "stm32f042", feature = "stm32f048", feature = "stm32f051", + feature = "stm32f058", feature = "stm32f071", feature = "stm32f072", feature = "stm32f091", diff --git a/src/gpio.rs b/src/gpio.rs index 6ab9e15..b3c688b 100644 --- a/src/gpio.rs +++ b/src/gpio.rs @@ -567,10 +567,10 @@ gpio!(GPIOC, gpioc, iopcen, PC, [ PC14: (pc14, 14, Input), PC15: (pc15, 15, Input), ]); - #[cfg(any( feature = "stm32f030", feature = "stm32f051", + feature = "stm32f058", feature = "stm32f070", feature = "stm32f071", feature = "stm32f072", @@ -595,11 +595,15 @@ gpio!(GPIOC, gpioc, iopcen, PC, [ PC15: (pc15, 15, Input), ]); -#[cfg(any(feature = "stm32f030", feature = "stm32f051", feature = "stm32f070"))] +#[cfg(any( + feature = "stm32f030", + feature = "stm32f051", + feature = "stm32f058", + feature = "stm32f070", +))] gpio!(GPIOD, gpiod, iopden, PD, [ PD2: (pd2, 2, Input), ]); - #[cfg(any(feature = "stm32f071", feature = "stm32f072", feature = "stm32f091"))] gpio!(GPIOD, gpiod, iopden, PD, [ PD0: (pd0, 0, Input), @@ -643,7 +647,7 @@ gpio!(GPIOD, gpiod, iopden, PD, [ // PE15: (pe15, 15, Input), // ]); -#[cfg(any(feature = "stm32f030", feature = "stm32f051"))] +#[cfg(any(feature = "stm32f030", feature = "stm32f051", feature = "stm32f058"))] gpio!(GPIOF, gpiof, iopfen, PF, [ PF0: (pf0, 0, Input), PF1: (pf1, 1, Input), diff --git a/src/i2c.rs b/src/i2c.rs index 587723a..6fd10bf 100644 --- a/src/i2c.rs +++ b/src/i2c.rs @@ -40,6 +40,7 @@ macro_rules! i2c_pins { feature = "stm32f042", feature = "stm32f048", feature = "stm32f051", + feature = "stm32f058", feature = "stm32f070", feature = "stm32f071", feature = "stm32f072", @@ -114,7 +115,7 @@ i2c_pins! { } } -#[cfg(any(feature = "stm32f030x8", feature = "stm32f051"))] +#[cfg(any(feature = "stm32f030x8", feature = "stm32f051", feature = "stm32f058"))] i2c_pins! { I2C2 => { scl => [gpiob::PB10>], @@ -178,6 +179,7 @@ i2c! { #[cfg(any( feature = "stm32f030xc", feature = "stm32f051", + feature = "stm32f058", feature = "stm32f070xb", feature = "stm32f071", feature = "stm32f072", diff --git a/src/lib.rs b/src/lib.rs index a46f8c0..90174c2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,7 +17,7 @@ pub use stm32f0::stm32f0x1 as stm32; #[cfg(any(feature = "stm32f042", feature = "stm32f072"))] pub use stm32f0::stm32f0x2 as stm32; -#[cfg(any(feature = "stm32f038", feature = "stm32f048"))] +#[cfg(any(feature = "stm32f038", feature = "stm32f048", feature = "stm32f058"))] pub use stm32f0::stm32f0x8 as stm32; #[cfg(feature = "device-selected")] diff --git a/src/serial.rs b/src/serial.rs index 0d657f2..c0dc52b 100644 --- a/src/serial.rs +++ b/src/serial.rs @@ -119,6 +119,7 @@ macro_rules! usart_pins { feature = "stm32f042", feature = "stm32f048", feature = "stm32f051", + feature = "stm32f058", feature = "stm32f071", ))] usart_pins! { @@ -154,6 +155,7 @@ usart_pins! { feature = "stm32f042", feature = "stm32f048", feature = "stm32f051", + feature = "stm32f058", feature = "stm32f070", feature = "stm32f071", feature = "stm32f072", @@ -370,6 +372,7 @@ usart! { feature = "stm32f042", feature = "stm32f048", feature = "stm32f051", + feature = "stm32f058", feature = "stm32f070", feature = "stm32f071", feature = "stm32f072", diff --git a/src/spi.rs b/src/spi.rs index 532a361..2a576ef 100644 --- a/src/spi.rs +++ b/src/spi.rs @@ -51,6 +51,7 @@ use crate::stm32::SPI1; feature = "stm32f030xc", feature = "stm32f048", feature = "stm32f051", + feature = "stm32f058", feature = "stm32f070xb", feature = "stm32f071", feature = "stm32f091", @@ -138,6 +139,7 @@ spi_pins! { feature = "stm32f030xc", feature = "stm32f048", feature = "stm32f051", + feature = "stm32f058", feature = "stm32f070xb", feature = "stm32f071", feature = "stm32f072", @@ -213,6 +215,7 @@ spi! { feature = "stm32f030xc", feature = "stm32f048", feature = "stm32f051", + feature = "stm32f058", feature = "stm32f070xb", feature = "stm32f071", feature = "stm32f091", diff --git a/src/timers.rs b/src/timers.rs index 2bbe6f7..2a1844f 100644 --- a/src/timers.rs +++ b/src/timers.rs @@ -228,6 +228,7 @@ timers! { feature = "stm32f042", feature = "stm32f048", feature = "stm32f051", + feature = "stm32f058", feature = "stm32f071", feature = "stm32f072", feature = "stm32f091", @@ -240,6 +241,7 @@ timers! { feature = "stm32f030x8", feature = "stm32f030xc", feature = "stm32f051", + feature = "stm32f058", feature = "stm32f070xb", feature = "stm32f071", feature = "stm32f072", From fca47168d2d4d400a7e2197c972a354df928198e Mon Sep 17 00:00:00 2001 From: Jesse Braham Date: Sun, 13 Jan 2019 20:32:54 -0800 Subject: [PATCH 4/7] Add support for stm32f078 --- Cargo.toml | 1 + src/adc.rs | 6 +++++- src/gpio.rs | 22 +++++++++++++++++++--- src/i2c.rs | 3 +++ src/lib.rs | 7 ++++++- src/serial.rs | 19 +++++++++++++++++-- src/spi.rs | 18 ++++++++++++++++-- src/timers.rs | 3 +++ 8 files changed, 70 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 44c2ce9..24b4591 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -65,6 +65,7 @@ stm32f070x6 = ["stm32f070"] stm32f070xb = ["stm32f070"] stm32f071 = ["stm32f0/stm32f0x1", "device-selected"] stm32f072 = ["stm32f0/stm32f0x2", "device-selected"] +stm32f078 = ["stm32f0/stm32f0x8", "device-selected"] stm32f091 = ["stm32f0/stm32f0x1", "device-selected"] [profile.dev] diff --git a/src/adc.rs b/src/adc.rs index 1d155d7..9531d3b 100644 --- a/src/adc.rs +++ b/src/adc.rs @@ -211,7 +211,8 @@ adc_pins!( feature = "stm32f070", feature = "stm32f071", feature = "stm32f072", - feature = "stm32f091" + feature = "stm32f078", + feature = "stm32f091", ))] adc_pins!( gpioc::PC0 => 10_u8, @@ -362,6 +363,7 @@ impl VRef { feature = "stm32f058", feature = "stm32f071", feature = "stm32f072", + feature = "stm32f078", feature = "stm32f091", ))] #[derive(Debug, Default)] @@ -377,6 +379,7 @@ pub struct VBat; feature = "stm32f058", feature = "stm32f071", feature = "stm32f072", + feature = "stm32f078", feature = "stm32f091", ))] adc_pins!( @@ -392,6 +395,7 @@ adc_pins!( feature = "stm32f058", feature = "stm32f071", feature = "stm32f072", + feature = "stm32f078", feature = "stm32f091", ))] impl VBat { diff --git a/src/gpio.rs b/src/gpio.rs index b3c688b..8d292a2 100644 --- a/src/gpio.rs +++ b/src/gpio.rs @@ -574,6 +574,7 @@ gpio!(GPIOC, gpioc, iopcen, PC, [ feature = "stm32f070", feature = "stm32f071", feature = "stm32f072", + feature = "stm32f078", feature = "stm32f091", ))] gpio!(GPIOC, gpioc, iopcen, PC, [ @@ -604,7 +605,12 @@ gpio!(GPIOC, gpioc, iopcen, PC, [ gpio!(GPIOD, gpiod, iopden, PD, [ PD2: (pd2, 2, Input), ]); -#[cfg(any(feature = "stm32f071", feature = "stm32f072", feature = "stm32f091"))] +#[cfg(any( + feature = "stm32f071", + feature = "stm32f072", + feature = "stm32f078", + feature = "stm32f091" +))] gpio!(GPIOD, gpiod, iopden, PD, [ PD0: (pd0, 0, Input), PD1: (pd1, 1, Input), @@ -627,7 +633,12 @@ gpio!(GPIOD, gpiod, iopden, PD, [ // TODO: The ST SVD files are missing the entire PE enable register. // Re-enable as soon as this gets fixed. -// #[cfg(any(feature = "stm32f071", feature = "stm32f072", feature = "stm32f091"))] +// #[cfg(any( +// feature = "stm32f071", +// feature = "stm32f072", +// feature = "stm32f078", +// feature = "stm32f091", +// ))] // gpio!(GPIOE, gpioe, iopeen, PE, [ // PE0: (pe0, 0, Input), // PE1: (pe1, 1, Input), @@ -684,7 +695,12 @@ gpio!(GPIOF, gpiof, iopfen, PF, [ PF1: (pf1, 1, Input), ]); -#[cfg(any(feature = "stm32f071", feature = "stm32f072", feature = "stm32f091"))] +#[cfg(any( + feature = "stm32f071", + feature = "stm32f072", + feature = "stm32f078", + feature = "stm32f091", +))] gpio!(GPIOF, gpiof, iopfen, PF, [ PF0: (pf0, 0, Input), PF1: (pf1, 1, Input), diff --git a/src/i2c.rs b/src/i2c.rs index 6fd10bf..382345b 100644 --- a/src/i2c.rs +++ b/src/i2c.rs @@ -44,6 +44,7 @@ macro_rules! i2c_pins { feature = "stm32f070", feature = "stm32f071", feature = "stm32f072", + feature = "stm32f078", feature = "stm32f091", ))] i2c_pins! { @@ -127,6 +128,7 @@ i2c_pins! { feature = "stm32f070xb", feature = "stm32f071", feature = "stm32f072", + feature = "stm32f078", feature = "stm32f091", ))] i2c_pins! { @@ -183,6 +185,7 @@ i2c! { feature = "stm32f070xb", feature = "stm32f071", feature = "stm32f072", + feature = "stm32f078", feature = "stm32f091", ))] i2c! { diff --git a/src/lib.rs b/src/lib.rs index 90174c2..51d5e0f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,7 +17,12 @@ pub use stm32f0::stm32f0x1 as stm32; #[cfg(any(feature = "stm32f042", feature = "stm32f072"))] pub use stm32f0::stm32f0x2 as stm32; -#[cfg(any(feature = "stm32f038", feature = "stm32f048", feature = "stm32f058"))] +#[cfg(any( + feature = "stm32f038", + feature = "stm32f048", + feature = "stm32f058", + feature = "stm32f078" +))] pub use stm32f0::stm32f0x8 as stm32; #[cfg(feature = "device-selected")] diff --git a/src/serial.rs b/src/serial.rs index c0dc52b..52eda7c 100644 --- a/src/serial.rs +++ b/src/serial.rs @@ -121,6 +121,7 @@ macro_rules! usart_pins { feature = "stm32f051", feature = "stm32f058", feature = "stm32f071", + feature = "stm32f078", ))] usart_pins! { USART1 => { @@ -159,6 +160,7 @@ usart_pins! { feature = "stm32f070", feature = "stm32f071", feature = "stm32f072", + feature = "stm32f078", feature = "stm32f091", ))] usart_pins! { @@ -167,7 +169,12 @@ usart_pins! { rx => [gpioa::PA3>, gpioa::PA15>], } } -#[cfg(any(feature = "stm32f072", feature = "stm32f071", feature = "stm32f091"))] +#[cfg(any( + feature = "stm32f072", + feature = "stm32f071", + feature = "stm32f078", + feature = "stm32f091" +))] usart_pins! { USART2 => { tx => [gpiod::PD5>], @@ -180,6 +187,7 @@ usart_pins! { feature = "stm32f070xb", feature = "stm32f071", feature = "stm32f072", + feature = "stm32f078", feature = "stm32f091", ))] usart_pins! { @@ -193,7 +201,12 @@ usart_pins! { rx => [gpioa::PA1>, gpioc::PC11>], } } -#[cfg(any(feature = "stm32f071", feature = "stm32f072", feature = "stm32f091"))] +#[cfg(any( + feature = "stm32f071", + feature = "stm32f072", + feature = "stm32f078", + feature = "stm32f091", +))] usart_pins! { USART3 => { tx => [gpiod::PD8>], @@ -376,6 +389,7 @@ usart! { feature = "stm32f070", feature = "stm32f071", feature = "stm32f072", + feature = "stm32f078", feature = "stm32f091", ))] usart! { @@ -386,6 +400,7 @@ usart! { feature = "stm32f070xb", feature = "stm32f071", feature = "stm32f072", + feature = "stm32f078", feature = "stm32f091", ))] usart! { diff --git a/src/spi.rs b/src/spi.rs index 2a576ef..5de57fc 100644 --- a/src/spi.rs +++ b/src/spi.rs @@ -54,6 +54,7 @@ use crate::stm32::SPI1; feature = "stm32f058", feature = "stm32f070xb", feature = "stm32f071", + feature = "stm32f078", feature = "stm32f091", ))] use crate::stm32::SPI2; @@ -125,7 +126,12 @@ spi_pins! { // TODO: The ST SVD files are missing the entire PE enable register. // So those pins do not exist in the register definitions. // Re-enable as soon as this gets fixed. -// #[cfg(any(feature = "stm32f071", feature = "stm32f072", feature = "stm32f091"))] +// #[cfg(any( +// feature = "stm32f071", +// feature = "stm32f072", +// feature = "stm32f078", +// feature = "stm32f091" +// ))] // spi_pins! { // SPI1 => { // sck => [gpioe::PE13>], @@ -143,6 +149,7 @@ spi_pins! { feature = "stm32f070xb", feature = "stm32f071", feature = "stm32f072", + feature = "stm32f078", feature = "stm32f091", ))] spi_pins! { @@ -157,6 +164,7 @@ spi_pins! { feature = "stm32f070xb", feature = "stm32f071", feature = "stm32f072", + feature = "stm32f078", feature = "stm32f091", ))] spi_pins! { @@ -166,7 +174,12 @@ spi_pins! { mosi => [gpioc::PC3>], } } -#[cfg(any(feature = "stm32f071", feature = "stm32f072", feature = "stm32f091"))] +#[cfg(any( + feature = "stm32f071", + feature = "stm32f072", + feature = "stm32f078", + feature = "stm32f091", +))] spi_pins! { SPI2 => { sck => [gpiod::PD1>], @@ -218,6 +231,7 @@ spi! { feature = "stm32f058", feature = "stm32f070xb", feature = "stm32f071", + feature = "stm32f078", feature = "stm32f091", ))] spi! { diff --git a/src/timers.rs b/src/timers.rs index 2a1844f..26fbaf6 100644 --- a/src/timers.rs +++ b/src/timers.rs @@ -231,6 +231,7 @@ timers! { feature = "stm32f058", feature = "stm32f071", feature = "stm32f072", + feature = "stm32f078", feature = "stm32f091", ))] timers! { @@ -245,6 +246,7 @@ timers! { feature = "stm32f070xb", feature = "stm32f071", feature = "stm32f072", + feature = "stm32f078", feature = "stm32f091", ))] timers! { @@ -256,6 +258,7 @@ timers! { feature = "stm32f030xc", feature = "stm32f070xb", feature = "stm32f072", + feature = "stm32f078", feature = "stm32f091", ))] timers! { From 32b14bf9766e2826a9a8f9fec284851e2da6bada Mon Sep 17 00:00:00 2001 From: Jesse Braham Date: Sun, 13 Jan 2019 20:56:12 -0800 Subject: [PATCH 5/7] Add support for stm32f098 --- Cargo.toml | 3 ++- src/adc.rs | 4 ++++ src/gpio.rs | 6 +++++- src/i2c.rs | 8 ++++++-- src/lib.rs | 3 ++- src/serial.rs | 15 +++++++++++---- src/spi.rs | 8 +++++++- src/timers.rs | 3 +++ 8 files changed, 40 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 24b4591..b52ddad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,7 +50,7 @@ panic-halt = "0.2.0" device-selected = [] rt = ["stm32f0/rt"] stm32f030 = ["stm32f0/stm32f0x0", "device-selected"] -stm32f030x4 = ["stm32f030x6"] +stm32f030x4 = ["stm32f030"] stm32f030x6 = ["stm32f030"] stm32f030x8 = ["stm32f030"] stm32f030xc = ["stm32f030"] @@ -67,6 +67,7 @@ stm32f071 = ["stm32f0/stm32f0x1", "device-selected"] stm32f072 = ["stm32f0/stm32f0x2", "device-selected"] stm32f078 = ["stm32f0/stm32f0x8", "device-selected"] stm32f091 = ["stm32f0/stm32f0x1", "device-selected"] +stm32f098 = ["stm32f0/stm32f0x8", "device-selected"] [profile.dev] debug = true diff --git a/src/adc.rs b/src/adc.rs index 9531d3b..78f7176 100644 --- a/src/adc.rs +++ b/src/adc.rs @@ -213,6 +213,7 @@ adc_pins!( feature = "stm32f072", feature = "stm32f078", feature = "stm32f091", + feature = "stm32f098", ))] adc_pins!( gpioc::PC0 => 10_u8, @@ -365,6 +366,7 @@ impl VRef { feature = "stm32f072", feature = "stm32f078", feature = "stm32f091", + feature = "stm32f098", ))] #[derive(Debug, Default)] /// Battery reference voltage (ADC Channel 18) @@ -381,6 +383,7 @@ pub struct VBat; feature = "stm32f072", feature = "stm32f078", feature = "stm32f091", + feature = "stm32f098", ))] adc_pins!( VBat => 18_u8, @@ -397,6 +400,7 @@ adc_pins!( feature = "stm32f072", feature = "stm32f078", feature = "stm32f091", + feature = "stm32f098", ))] impl VBat { /// Init a new VBat diff --git a/src/gpio.rs b/src/gpio.rs index 8d292a2..1efa46d 100644 --- a/src/gpio.rs +++ b/src/gpio.rs @@ -576,6 +576,7 @@ gpio!(GPIOC, gpioc, iopcen, PC, [ feature = "stm32f072", feature = "stm32f078", feature = "stm32f091", + feature = "stm32f098", ))] gpio!(GPIOC, gpioc, iopcen, PC, [ PC0: (pc0, 0, Input), @@ -609,7 +610,8 @@ gpio!(GPIOD, gpiod, iopden, PD, [ feature = "stm32f071", feature = "stm32f072", feature = "stm32f078", - feature = "stm32f091" + feature = "stm32f091", + feature = "stm32f098", ))] gpio!(GPIOD, gpiod, iopden, PD, [ PD0: (pd0, 0, Input), @@ -638,6 +640,7 @@ gpio!(GPIOD, gpiod, iopden, PD, [ // feature = "stm32f072", // feature = "stm32f078", // feature = "stm32f091", +// feature = "stm32f098", // ))] // gpio!(GPIOE, gpioe, iopeen, PE, [ // PE0: (pe0, 0, Input), @@ -700,6 +703,7 @@ gpio!(GPIOF, gpiof, iopfen, PF, [ feature = "stm32f072", feature = "stm32f078", feature = "stm32f091", + feature = "stm32f098", ))] gpio!(GPIOF, gpiof, iopfen, PF, [ PF0: (pf0, 0, Input), diff --git a/src/i2c.rs b/src/i2c.rs index 382345b..a8708f5 100644 --- a/src/i2c.rs +++ b/src/i2c.rs @@ -46,6 +46,7 @@ macro_rules! i2c_pins { feature = "stm32f072", feature = "stm32f078", feature = "stm32f091", + feature = "stm32f098", ))] i2c_pins! { I2C1 => { @@ -60,6 +61,7 @@ i2c_pins! { feature = "stm32f042", feature = "stm32f048", feature = "stm32f091", + feature = "stm32f098", ))] i2c_pins! { I2C1 => { @@ -94,7 +96,7 @@ i2c_pins! { sda => [gpiob::PB14>], } } -#[cfg(any(feature = "stm32f042", feature = "stm32f030xc"))] +#[cfg(any(feature = "stm32f042", feature = "stm32f030xc", feature = "stm32f098"))] i2c_pins! { I2C1 => { scl => [gpiof::PF1>], @@ -130,6 +132,7 @@ i2c_pins! { feature = "stm32f072", feature = "stm32f078", feature = "stm32f091", + feature = "stm32f098", ))] i2c_pins! { I2C2 => { @@ -137,7 +140,7 @@ i2c_pins! { sda => [gpiob::PB11>, gpiob::PB14>], } } -#[cfg(feature = "stm32f091")] +#[cfg(any(feature = "stm32f091", feature = "stm32f098"))] i2c_pins! { I2C2 => { scl => [gpioa::PA11>], @@ -187,6 +190,7 @@ i2c! { feature = "stm32f072", feature = "stm32f078", feature = "stm32f091", + feature = "stm32f098", ))] i2c! { I2C2: (i2c2, i2c2en, i2c2rst, apb1enr, apb1rstr), diff --git a/src/lib.rs b/src/lib.rs index 51d5e0f..510e1b4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,7 +21,8 @@ pub use stm32f0::stm32f0x2 as stm32; feature = "stm32f038", feature = "stm32f048", feature = "stm32f058", - feature = "stm32f078" + feature = "stm32f078", + feature = "stm32f098", ))] pub use stm32f0::stm32f0x8 as stm32; diff --git a/src/serial.rs b/src/serial.rs index 52eda7c..f95107f 100644 --- a/src/serial.rs +++ b/src/serial.rs @@ -122,6 +122,7 @@ macro_rules! usart_pins { feature = "stm32f058", feature = "stm32f071", feature = "stm32f078", + feature = "stm32f098", ))] usart_pins! { USART1 => { @@ -162,6 +163,7 @@ usart_pins! { feature = "stm32f072", feature = "stm32f078", feature = "stm32f091", + feature = "stm32f098", ))] usart_pins! { USART2 => { @@ -173,7 +175,8 @@ usart_pins! { feature = "stm32f072", feature = "stm32f071", feature = "stm32f078", - feature = "stm32f091" + feature = "stm32f091", + feature = "stm32f098", ))] usart_pins! { USART2 => { @@ -189,6 +192,7 @@ usart_pins! { feature = "stm32f072", feature = "stm32f078", feature = "stm32f091", + feature = "stm32f098", ))] usart_pins! { USART3 => { @@ -206,6 +210,7 @@ usart_pins! { feature = "stm32f072", feature = "stm32f078", feature = "stm32f091", + feature = "stm32f098", ))] usart_pins! { USART3 => { @@ -224,7 +229,7 @@ usart_pins! { // } // } -#[cfg(any(feature = "stm32f030xc", feature = "stm32f091"))] +#[cfg(any(feature = "stm32f030xc", feature = "stm32f091", feature = "stm32f098"))] usart_pins! { USART5 => { tx => [gpiob::PB3>, gpioc::PC12>], @@ -237,7 +242,7 @@ usart_pins! { } // TODO: The ST SVD files are missing the entire PE enable register. // Re-enable as soon as this gets fixed. -#[cfg(feature = "stm32f091")] +#[cfg(any(feature = "stm32f091", feature = "stm32f098"))] usart_pins! { // USART5 => { // tx => [gpioe::PE10>], @@ -391,6 +396,7 @@ usart! { feature = "stm32f072", feature = "stm32f078", feature = "stm32f091", + feature = "stm32f098", ))] usart! { USART2: (usart2, usart2tx, usart2rx,usart2en, apb1enr), @@ -402,12 +408,13 @@ usart! { feature = "stm32f072", feature = "stm32f078", feature = "stm32f091", + feature = "stm32f098", ))] usart! { USART3: (usart3, usart3tx, usart3rx,usart3en, apb1enr), USART4: (usart4, usart4tx, usart4rx,usart4en, apb1enr), } -#[cfg(any(feature = "stm32f030xc", feature = "stm32f091"))] +#[cfg(any(feature = "stm32f030xc", feature = "stm32f091", feature = "stm32f098"))] usart! { USART5: (usart5, usart5tx, usart5rx,usart5en, apb1enr), USART6: (usart6, usart6tx, usart6rx,usart6en, apb2enr), diff --git a/src/spi.rs b/src/spi.rs index 5de57fc..12ddeb9 100644 --- a/src/spi.rs +++ b/src/spi.rs @@ -56,6 +56,7 @@ use crate::stm32::SPI1; feature = "stm32f071", feature = "stm32f078", feature = "stm32f091", + feature = "stm32f098", ))] use crate::stm32::SPI2; @@ -130,7 +131,8 @@ spi_pins! { // feature = "stm32f071", // feature = "stm32f072", // feature = "stm32f078", -// feature = "stm32f091" +// feature = "stm32f091", +// feature = "stm32f098", // ))] // spi_pins! { // SPI1 => { @@ -151,6 +153,7 @@ spi_pins! { feature = "stm32f072", feature = "stm32f078", feature = "stm32f091", + feature = "stm32f098", ))] spi_pins! { SPI2 => { @@ -166,6 +169,7 @@ spi_pins! { feature = "stm32f072", feature = "stm32f078", feature = "stm32f091", + feature = "stm32f098", ))] spi_pins! { SPI2 => { @@ -179,6 +183,7 @@ spi_pins! { feature = "stm32f072", feature = "stm32f078", feature = "stm32f091", + feature = "stm32f098", ))] spi_pins! { SPI2 => { @@ -233,6 +238,7 @@ spi! { feature = "stm32f071", feature = "stm32f078", feature = "stm32f091", + feature = "stm32f098", ))] spi! { SPI2: (spi2, spi2en, spi2rst, apb1enr, apb1rstr), diff --git a/src/timers.rs b/src/timers.rs index 26fbaf6..f33ad69 100644 --- a/src/timers.rs +++ b/src/timers.rs @@ -233,6 +233,7 @@ timers! { feature = "stm32f072", feature = "stm32f078", feature = "stm32f091", + feature = "stm32f098", ))] timers! { TIM2: (tim2, tim2en, tim2rst, apb1enr, apb1rstr), @@ -248,6 +249,7 @@ timers! { feature = "stm32f072", feature = "stm32f078", feature = "stm32f091", + feature = "stm32f098", ))] timers! { TIM6: (tim6, tim6en, tim6rst, apb1enr, apb1rstr), @@ -260,6 +262,7 @@ timers! { feature = "stm32f072", feature = "stm32f078", feature = "stm32f091", + feature = "stm32f098", ))] timers! { TIM7: (tim7, tim7en, tim7rst, apb1enr, apb1rstr), From e3d7111c08be0ce1881bf01868fdef8fbd7e3416 Mon Sep 17 00:00:00 2001 From: Jesse Braham Date: Sun, 13 Jan 2019 21:08:13 -0800 Subject: [PATCH 6/7] Fix some long-standing errors and inconsistencies for USARTS --- src/serial.rs | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/serial.rs b/src/serial.rs index f95107f..11d9253 100644 --- a/src/serial.rs +++ b/src/serial.rs @@ -116,18 +116,23 @@ macro_rules! usart_pins { #[cfg(any( feature = "stm32f030", + feature = "stm32f031", + feature = "stm32f038", feature = "stm32f042", feature = "stm32f048", feature = "stm32f051", feature = "stm32f058", + feature = "stm32f070", feature = "stm32f071", + feature = "stm32f072", feature = "stm32f078", + feature = "stm32f091", feature = "stm32f098", ))] usart_pins! { - USART1 => { + USART1 => { tx => [gpioa::PA9>, gpiob::PB6>], - rx => [gpioa::PA10>, gpiob::PB6>], + rx => [gpioa::PA10>, gpiob::PB7>], } } #[cfg(any(feature = "stm32f030x6", feature = "stm32f031", feature = "stm32f038"))] @@ -137,19 +142,6 @@ usart_pins! { rx => [gpioa::PA3>, gpioa::PA15>], } } -#[cfg(any( - feature = "stm32f031", - feature = "stm32f038", - feature = "stm32f070", - feature = "stm32f072", - feature = "stm32f091", -))] -usart_pins! { - USART1 => { - tx => [gpioa::PA9>, gpiob::PB6>], - rx => [gpioa::PA10>, gpiob::PB7>], - } -} #[cfg(any( feature = "stm32f030x8", From 1c7e2cd93b4e760c25bc4f2c72d79de0ca0c3d8f Mon Sep 17 00:00:00 2001 From: Jesse Braham Date: Sun, 13 Jan 2019 21:15:28 -0800 Subject: [PATCH 7/7] Update CHANGELOG and README --- CHANGELOG.md | 4 ++++ README.md | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 660286c..8be387f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +### Added + +- Support for stm32f0x8 line - @jessebraham + ## [v0.12.0] - 2019-01-13 ### Added diff --git a/README.md b/README.md index eb30196..9b66cd8 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ stm32f0xx-hal [_stm32f0xx-hal_](https://github.com/stm32-rs/stm32f0xx-hal) contains a hardware abstraction on top of the peripheral access API for the STMicro STM32F0xx family of microcontrollers. -This crate replaces the [stm32f042-hal](https://github.com/therealprof/stm32f042-hal) by a more ubiqitous version suitable for additional families. The idea behind this crate is to gloss over the slight differences in the various peripherals available on those MCUs so a HAL can be written for all chips in that same family without having to cut and paste crates for every single model. +This crate replaces the [stm32f042-hal](https://github.com/therealprof/stm32f042-hal) by a more ubiquitous version suitable for additional families. The idea behind this crate is to gloss over the slight differences in the various peripherals available on those MCUs so a HAL can be written for all chips in that same family without having to cut and paste crates for every single model. This crate relies on Adam Greig's fantastic [stm32f0](https://crates.io/crates/stm32f0) crate to provide appropriate register definitions, and implements a partial set of the [embedded-hal](https://github.com/rust-embedded/embedded-hal) traits. Some of the implementation was shamelessly adapted from the [stm32f103xx-hal](https://github.com/japaric/stm32f103xx-hal) crate by Jorge Aparicio. @@ -19,12 +19,17 @@ Supported Configurations * __stm32f030__ (stm32f030x4, stm32f030x6, stm32f030x8, stm32f030xc) * __stm32f031__ +* __stm32f038__ * __stm32f042__ +* __stm32f048__ * __stm32f051__ +* __stm32f058__ * __stm32f070__ (stm32f070x6, stm32f070xb) * __stm32f071__ * __stm32f072__ +* __stm32f078__ * __stm32f091__ +* __stm32f098__ Getting Started