From 632696ef5433e0bf886039ce405c2f465d0ff669 Mon Sep 17 00:00:00 2001 From: Gaute Hope Date: Sat, 26 Feb 2022 23:42:52 +0100 Subject: [PATCH 1/5] add support for stm32l4r5 --- Cargo.toml | 2 +- src/dma.rs | 4 ++-- src/dmamux.rs | 16 ++++++++-------- src/gpio.rs | 8 ++++---- src/i2c.rs | 6 +++--- src/lib.rs | 11 ++++++++--- src/rcc/enable.rs | 19 +++++++++++++------ src/serial.rs | 10 +++++----- src/spi.rs | 6 +++--- src/timer.rs | 2 +- src/watchdog.rs | 4 ++++ 11 files changed, 52 insertions(+), 36 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c2ceaec0..1404045f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -96,7 +96,7 @@ stm32l4a6 = [ "stm32l4/stm32l4x6" ] # L4+ series PAC support?? #stm32l4p5 = [ "stm32l4/stm32l4x5" ] #stm32l4q5 = [ "stm32l4/stm32l4x5" ] -#stm32l4r5 = [ "stm32l4/stm32l4x5" ] +stm32l4r5 = [ "stm32l4/stm32l4r5" ] #stm32l4s5 = [ "stm32l4/stm32l4x5" ] # L4x7 diff --git a/src/dma.rs b/src/dma.rs index 160dfd69..d2eb2985 100644 --- a/src/dma.rs +++ b/src/dma.rs @@ -647,7 +647,7 @@ macro_rules! dma { #[cfg(not(any( // feature = "stm32l4p5", // feature = "stm32l4q5", - // feature = "stm32l4r5", + feature = "stm32l4r5", // feature = "stm32l4s5", // feature = "stm32l4r7", // feature = "stm32l4s7", @@ -1085,7 +1085,7 @@ macro_rules! dma { #[cfg(any( // feature = "stm32l4p5", // feature = "stm32l4q5", - // feature = "stm32l4r5", + feature = "stm32l4r5", // feature = "stm32l4s5", // feature = "stm32l4r7", // feature = "stm32l4s7", diff --git a/src/dmamux.rs b/src/dmamux.rs index 83bed1c2..edd9c9e6 100644 --- a/src/dmamux.rs +++ b/src/dmamux.rs @@ -11,7 +11,7 @@ use crate::dma::{dma1, dma2}; #[cfg(any( // feature = "stm32l4p5", // feature = "stm32l4q5", - // feature = "stm32l4r5", + feature = "stm32l4r5", // feature = "stm32l4s5", // feature = "stm32l4r7", // feature = "stm32l4s7", @@ -132,7 +132,7 @@ pub enum DmaInput { #[cfg(any( // feature = "stm32l4p5", // feature = "stm32l4q5", - // feature = "stm32l4r5", + feature = "stm32l4r5", // feature = "stm32l4s5", // feature = "stm32l4r7", // feature = "stm32l4s7", @@ -240,7 +240,7 @@ enum DMAREQ_ID_A { #[cfg(any( // feature = "stm32l4p5", // feature = "stm32l4q5", - // feature = "stm32l4r5", + feature = "stm32l4r5", // feature = "stm32l4s5", // feature = "stm32l4r7", // feature = "stm32l4s7", @@ -256,7 +256,7 @@ impl From for u8 { #[cfg(any( // feature = "stm32l4p5", // feature = "stm32l4q5", - // feature = "stm32l4r5", + feature = "stm32l4r5", // feature = "stm32l4s5", // feature = "stm32l4r7", // feature = "stm32l4s7", @@ -372,7 +372,7 @@ impl TryFrom for DMAREQ_ID_A { #[cfg(not(any( // feature = "stm32l4p5", // feature = "stm32l4q5", - // feature = "stm32l4r5", + feature = "stm32l4r5", // feature = "stm32l4s5", // feature = "stm32l4r7", // feature = "stm32l4s7", @@ -419,7 +419,7 @@ macro_rules! cselr { #[cfg(not(any( // feature = "stm32l4p5", // feature = "stm32l4q5", - // feature = "stm32l4r5", + feature = "stm32l4r5", // feature = "stm32l4s5", // feature = "stm32l4r7", // feature = "stm32l4s7", @@ -565,7 +565,7 @@ macro_rules! dmamux { #[cfg(any( // feature = "stm32l4p5", // feature = "stm32l4q5", - // feature = "stm32l4r5", + feature = "stm32l4r5", // feature = "stm32l4s5", // feature = "stm32l4r7", // feature = "stm32l4s7", @@ -586,7 +586,7 @@ macro_rules! dmamux { #[cfg(not(any( // feature = "stm32l4p5", // feature = "stm32l4q5", - // feature = "stm32l4r5", + feature = "stm32l4r5", // feature = "stm32l4s5", // feature = "stm32l4r7", // feature = "stm32l4s7", diff --git a/src/gpio.rs b/src/gpio.rs index 88bf9db7..79fc9f6a 100644 --- a/src/gpio.rs +++ b/src/gpio.rs @@ -712,7 +712,7 @@ gpio!(GPIOE, gpioe, PEx, 'E', 4, [ feature = "stm32l4a6", // feature = "stm32l4p5", // feature = "stm32l4q5", - // feature = "stm32l4r5", + feature = "stm32l4r5", // feature = "stm32l4s5", // feature = "stm32l4r7", // feature = "stm32l4s7", @@ -747,7 +747,7 @@ gpio!(GPIOF, gpiof, PFx, 'F', 5, [ feature = "stm32l4a6", // feature = "stm32l4p5", // feature = "stm32l4q5", - // feature = "stm32l4r5", + feature = "stm32l4r5", // feature = "stm32l4s5", // feature = "stm32l4r7", // feature = "stm32l4s7", @@ -794,7 +794,7 @@ impl Gpio

{ feature = "stm32l4a6", // feature = "stm32l4p5", // feature = "stm32l4q5", - // feature = "stm32l4r5", + feature = "stm32l4r5", // feature = "stm32l4s5", // feature = "stm32l4r7", // feature = "stm32l4s7", @@ -812,7 +812,7 @@ impl Gpio

{ feature = "stm32l4a6", // feature = "stm32l4p5", // feature = "stm32l4q5", - // feature = "stm32l4r5", + feature = "stm32l4r5", // feature = "stm32l4s5", // feature = "stm32l4r7", // feature = "stm32l4s7", diff --git a/src/i2c.rs b/src/i2c.rs index 7e8b5dc9..89eda5be 100644 --- a/src/i2c.rs +++ b/src/i2c.rs @@ -12,7 +12,7 @@ use crate::hal::blocking::i2c::{Read, Write, WriteRead}; feature = "stm32l4a6", // feature = "stm32l4p5", // feature = "stm32l4q5", - // feature = "stm32l4r5", + feature = "stm32l4r5", // feature = "stm32l4s5", // feature = "stm32l4r7", // feature = "stm32l4s7", @@ -208,7 +208,7 @@ hal!(I2C3, i2c3); feature = "stm32l4a6", // feature = "stm32l4p5", // feature = "stm32l4q5", - // feature = "stm32l4r5", + feature = "stm32l4r5", // feature = "stm32l4s5", // feature = "stm32l4r7", // feature = "stm32l4s7", @@ -613,7 +613,7 @@ mod stm32l4x6_pins { #[cfg(any( // feature = "stm32l4p5", // feature = "stm32l4q5", - // feature = "stm32l4r5", + feature = "stm32l4r5", // feature = "stm32l4s5", // feature = "stm32l4r7", // feature = "stm32l4s7", diff --git a/src/lib.rs b/src/lib.rs index 3668ad6a..f82ec232 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -30,7 +30,7 @@ // note L4+ PAC support is mostly missing so other than r9/s9 these features don't actually exist yet // feature = "stm32l4p5", // feature = "stm32l4q5", - // feature = "stm32l4r5", + feature = "stm32l4r5", // feature = "stm32l4s5", // feature = "stm32l4r7", // feature = "stm32l4s7", @@ -44,7 +44,8 @@ This crate requires one of the following features enabled: stm32l431, stm32l451, stm32l471 stm32l412, stm32l422, stm32l432, stm32l442, stm32l452, stm32l462 stm32l433, stm32l443 - stm32l475, + stm32l475, + stm32l4r5, stm32l476, stm32l486, stm32l496, stm32l4a6 stm32l4r9, stm32l4s9 " @@ -110,6 +111,9 @@ pub use stm32l4::stm32l4x5 as pac; ))] pub use stm32l4::stm32l4x6 as pac; +#[cfg(any(feature = "stm32l4r5"))] +pub use stm32l4::stm32l4r5 as pac; + #[cfg(any(feature = "stm32l4r9", feature = "stm32l4s9",))] pub use stm32l4::stm32l4r9 as pac; @@ -123,7 +127,7 @@ pub mod traits; #[cfg(not(any(feature = "stm32l4r9", feature = "stm32l4s9",)))] pub mod adc; -#[cfg(not(any(feature = "stm32l4r9", feature = "stm32l4s9",)))] +#[cfg(not(any(feature = "stm32lr5", feature = "stm32l4r9", feature = "stm32l4s9",)))] #[cfg(not(any(feature = "stm32l412",)))] pub mod can; pub mod crc; @@ -152,6 +156,7 @@ pub mod pwr; #[cfg(not(any( feature = "stm32l433", feature = "stm32l443", + feature = "stm32l4r5", feature = "stm32l4r9", feature = "stm32l4s9", )))] diff --git a/src/rcc/enable.rs b/src/rcc/enable.rs index 79c9baa0..08fa8515 100644 --- a/src/rcc/enable.rs +++ b/src/rcc/enable.rs @@ -143,7 +143,7 @@ bus! { #[cfg(not(any( // feature = "stm32l4p5", // feature = "stm32l4q5", - // feature = "stm32l4r5", + feature = "stm32l4r5", // feature = "stm32l4s5", // feature = "stm32l4r7", // feature = "stm32l4s7", @@ -161,10 +161,17 @@ bus! { } // L4+ +#[cfg(any(feature = "stm32l4r5"))] +bus! { + ADC1 => (AHB2, adcen, adcfssmen, adcrst), // 13 + + FIREWALL => (APB2, fwen,,), // 7 + LTCD => (APB2, ltdcen, ltdcsmen, ltdcrst), // 26 +} + #[cfg(any( // feature = "stm32l4p5", // feature = "stm32l4q5", - // feature = "stm32l4r5", // feature = "stm32l4s5", // feature = "stm32l4r7", // feature = "stm32l4s7", @@ -188,7 +195,7 @@ bus! { feature = "stm32l4a6", // feature = "stm32l4p5", // feature = "stm32l4q5", - // feature = "stm32l4r5", + feature = "stm32l4r5", // feature = "stm32l4s5", // feature = "stm32l4r7", // feature = "stm32l4s7", @@ -257,7 +264,7 @@ bus! { feature = "stm32l443", // feature = "stm32l4p5", // feature = "stm32l4q5", - // feature = "stm32l4r5", + feature = "stm32l4r5", // feature = "stm32l4s5", // feature = "stm32l4r7", // feature = "stm32l4s7", @@ -324,7 +331,7 @@ bus! { feature = "stm32l4a6", // feature = "stm32l4p5", // feature = "stm32l4q5", - // feature = "stm32l4r5", + feature = "stm32l4r5", // feature = "stm32l4s5", // feature = "stm32l4r7", // feature = "stm32l4s7", @@ -361,7 +368,7 @@ bus! { #[cfg(any( // feature = "stm32l4p5", // feature = "stm32l4q5", - // feature = "stm32l4r5", + feature = "stm32l4r5", // feature = "stm32l4s5", // feature = "stm32l4r7", // feature = "stm32l4s7", diff --git a/src/serial.rs b/src/serial.rs index 2e36c7b4..4a18de9d 100644 --- a/src/serial.rs +++ b/src/serial.rs @@ -35,7 +35,7 @@ use crate::time::{Bps, U32Ext}; feature = "stm32l4a6", // feature = "stm32l4p5", // feature = "stm32l4q5", - // feature = "stm32l4r5", + feature = "stm32l4r5", // feature = "stm32l4s5", // feature = "stm32l4r7", // feature = "stm32l4s7", @@ -869,7 +869,7 @@ hal! { feature = "stm32l4a6", // feature = "stm32l4p5", // feature = "stm32l4q5", - // feature = "stm32l4r5", + feature = "stm32l4r5", // feature = "stm32l4s5", // feature = "stm32l4r7", // feature = "stm32l4s7", @@ -890,7 +890,7 @@ hal! { feature = "stm32l4a6", // feature = "stm32l4p5", // feature = "stm32l4q5", - // feature = "stm32l4r5", + feature = "stm32l4r5", // feature = "stm32l4s5", // feature = "stm32l4r7", // feature = "stm32l4s7", @@ -1046,7 +1046,7 @@ impl_pin_traits! { feature = "stm32l4a6", // feature = "stm32l4p5", // feature = "stm32l4q5", - // feature = "stm32l4r5", + feature = "stm32l4r5", // feature = "stm32l4s5", // feature = "stm32l4r7", // feature = "stm32l4s7", @@ -1074,7 +1074,7 @@ impl_pin_traits! { feature = "stm32l4a6", // feature = "stm32l4p5", // feature = "stm32l4q5", - // feature = "stm32l4r5", + feature = "stm32l4r5", // feature = "stm32l4s5", // feature = "stm32l4r7", // feature = "stm32l4s7", diff --git a/src/spi.rs b/src/spi.rs index b29cb8ab..428452a2 100644 --- a/src/spi.rs +++ b/src/spi.rs @@ -277,7 +277,7 @@ use crate::gpio::gpiod::*; feature = "stm32l4a6", // feature = "stm32l4p5", // feature = "stm32l4q5", - // feature = "stm32l4r5", + feature = "stm32l4r5", // feature = "stm32l4s5", // feature = "stm32l4r7", // feature = "stm32l4s7", @@ -307,7 +307,7 @@ pins!(SPI1, 5, feature = "stm32l4a6", // feature = "stm32l4p5", // feature = "stm32l4q5", - // feature = "stm32l4r5", + feature = "stm32l4r5", // feature = "stm32l4s5", // feature = "stm32l4r7", // feature = "stm32l4s7", @@ -340,7 +340,7 @@ pins!(SPI3, 6, feature = "stm32l4a6", // feature = "stm32l4p5", // feature = "stm32l4q5", - // feature = "stm32l4r5", + feature = "stm32l4r5", // feature = "stm32l4s5", // feature = "stm32l4r7", // feature = "stm32l4s7", diff --git a/src/timer.rs b/src/timer.rs index 739966fe..aecee2c3 100644 --- a/src/timer.rs +++ b/src/timer.rs @@ -44,7 +44,7 @@ use crate::stm32::{TIM15, TIM16, TIM2, TIM6}; feature = "stm32l4a6", // feature = "stm32l4p5", // feature = "stm32l4q5", - // feature = "stm32l4r5", + feature = "stm32l4r5", // feature = "stm32l4s5", // feature = "stm32l4r7", // feature = "stm32l4s7", diff --git a/src/watchdog.rs b/src/watchdog.rs index de60d9c9..0a535b5d 100644 --- a/src/watchdog.rs +++ b/src/watchdog.rs @@ -39,6 +39,8 @@ impl IndependentWatchdog { feature = "stm32l462", feature = "stm32l433", feature = "stm32l443", + feature = "stm32l4r5", + feature = "stm32l4r9", ))] dbgmcu.apb1fzr1.modify(|_, w| w.dbg_iwdg_stop().bit(stop)); #[cfg(not(any( @@ -53,6 +55,8 @@ impl IndependentWatchdog { feature = "stm32l462", feature = "stm32l433", feature = "stm32l443", + feature = "stm32l4r5", + feature = "stm32l4r9", )))] dbgmcu.apb1_fzr1.modify(|_, w| w.dbg_iwdg_stop().bit(stop)); } From 0af79e5b7edff71d6c0ea9d317f1beffc44fd8b9 Mon Sep 17 00:00:00 2001 From: Gaute Hope Date: Mon, 28 Feb 2022 18:02:59 +0100 Subject: [PATCH 2/5] add TIM3, TIM4, TIM5, TIM17 --- src/timer.rs | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/timer.rs b/src/timer.rs index aecee2c3..f37df24e 100644 --- a/src/timer.rs +++ b/src/timer.rs @@ -51,7 +51,7 @@ use crate::stm32::{TIM15, TIM16, TIM2, TIM6}; feature = "stm32l4r9", feature = "stm32l4s9", ))] -use crate::stm32::{TIM17, TIM4, TIM5}; +use crate::stm32::{TIM17, TIM3, TIM4, TIM5}; // TIM1/TIM8 ("Advcanced Control Timers") -> no impl // TIM2/TIM3/TIM4/TIM5 ("General Purpose Timers") @@ -267,21 +267,20 @@ hal! { // missing PAC support // RCC_APB1RSTR1->TIM3RST not defined -/* #[cfg(any( - feature = "stm32l451", - feature = "stm32l452", - feature = "stm32l462", - feature = "stm32l471", - feature = "stm32l475", - feature = "stm32l476", - feature = "stm32l485", - feature = "stm32l486", - feature = "stm32l496", - feature = "stm32l4a6", + // feature = "stm32l451", + // feature = "stm32l452", + // feature = "stm32l462", + // feature = "stm32l471", + // feature = "stm32l475", + // feature = "stm32l476", + // feature = "stm32l485", + // feature = "stm32l486", + // feature = "stm32l496", + // feature = "stm32l4a6", // feature = "stm32l4p5", // feature = "stm32l4q5", - // feature = "stm32l4r5", + feature = "stm32l4r5", // feature = "stm32l4s5", // feature = "stm32l4r7", // feature = "stm32l4s7", @@ -289,9 +288,8 @@ hal! { feature = "stm32l4s9", ))] hal! { - TIM3: (tim3, free_running_tim3, tim3en, tim3rst, APB1R1, u32), + TIM3: (tim3, free_running_tim3, APB1R1, u16), } -*/ #[cfg(not(any( feature = "stm32l412", @@ -313,7 +311,7 @@ hal! { feature = "stm32l4a6", // feature = "stm32l4p5", // feature = "stm32l4q5", - // feature = "stm32l4r5", + feature = "stm32l4r5", // feature = "stm32l4s5", // feature = "stm32l4r7", // feature = "stm32l4s7", From 3678fe7ad4753da2aa12b9bd5b1dc3904c9b94c4 Mon Sep 17 00:00:00 2001 From: Gaute Hope Date: Tue, 1 Mar 2022 14:16:43 +0100 Subject: [PATCH 3/5] i2c: allow writing 0 bytes (typically used to ping for devices) --- src/i2c.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i2c.rs b/src/i2c.rs index 89eda5be..f2cad15f 100644 --- a/src/i2c.rs +++ b/src/i2c.rs @@ -303,7 +303,7 @@ where fn write(&mut self, addr: u8, bytes: &[u8]) -> Result<(), Error> { // TODO support transfers of more than 255 bytes - assert!(bytes.len() < 256 && bytes.len() > 0); + assert!(bytes.len() < 256); // Wait for any previous address sequence to end // automatically. This could be up to 50% of a bus From 0ee92063de4a8497205285ceed1ae219de4eee3a Mon Sep 17 00:00:00 2001 From: Gaute Hope Date: Thu, 3 Mar 2022 10:35:31 +0100 Subject: [PATCH 4/5] add r5 to CI --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 84357e1e..e35a2036 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,13 +50,14 @@ jobs: command: test args: --lib --target x86_64-unknown-linux-gnu --features rt,unproven,${{ matrix.mcu.id }}${{ matrix.mcu.additional-features }} - ci-r9: + ci-rx: runs-on: ubuntu-latest strategy: matrix: rust: - stable mcu: + - { id: stm32l4r5, additional-features: "" } - { id: stm32l4r9, additional-features: "" } - { id: stm32l4s9, additional-features: "" } From 39a6bb83d92ce8c1a2e5e773b713c65cf6213188 Mon Sep 17 00:00:00 2001 From: Philip A Reimer Date: Fri, 18 Mar 2022 20:56:35 -0600 Subject: [PATCH 5/5] add stm32l4r5 to otg_fs feature list --- src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib.rs b/src/lib.rs index f82ec232..06d08c4c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -147,6 +147,7 @@ pub mod lptimer; feature = "stm32l486", feature = "stm32l496", feature = "stm32l4a6", + feature = "stm32l4r5", ) ))] pub mod otg_fs;