Skip to content

Commit

Permalink
add support for stm32l4r5
Browse files Browse the repository at this point in the history
  • Loading branch information
gauteh committed Feb 26, 2022
1 parent 325a19c commit 9d1767e
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 37 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/dma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ macro_rules! dma {
#[cfg(not(any(
// feature = "stm32l4p5",
// feature = "stm32l4q5",
// feature = "stm32l4r5",
feature = "stm32l4r5",
// feature = "stm32l4s5",
// feature = "stm32l4r7",
// feature = "stm32l4s7",
Expand Down Expand Up @@ -1085,7 +1085,7 @@ macro_rules! dma {
#[cfg(any(
// feature = "stm32l4p5",
// feature = "stm32l4q5",
// feature = "stm32l4r5",
feature = "stm32l4r5",
// feature = "stm32l4s5",
// feature = "stm32l4r7",
// feature = "stm32l4s7",
Expand Down
16 changes: 8 additions & 8 deletions src/dmamux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -132,7 +132,7 @@ pub enum DmaInput {
#[cfg(any(
// feature = "stm32l4p5",
// feature = "stm32l4q5",
// feature = "stm32l4r5",
feature = "stm32l4r5",
// feature = "stm32l4s5",
// feature = "stm32l4r7",
// feature = "stm32l4s7",
Expand Down Expand Up @@ -240,7 +240,7 @@ enum DMAREQ_ID_A {
#[cfg(any(
// feature = "stm32l4p5",
// feature = "stm32l4q5",
// feature = "stm32l4r5",
feature = "stm32l4r5",
// feature = "stm32l4s5",
// feature = "stm32l4r7",
// feature = "stm32l4s7",
Expand All @@ -256,7 +256,7 @@ impl From<DMAREQ_ID_A> for u8 {
#[cfg(any(
// feature = "stm32l4p5",
// feature = "stm32l4q5",
// feature = "stm32l4r5",
feature = "stm32l4r5",
// feature = "stm32l4s5",
// feature = "stm32l4r7",
// feature = "stm32l4s7",
Expand Down Expand Up @@ -372,7 +372,7 @@ impl TryFrom<DmaInput> for DMAREQ_ID_A {
#[cfg(not(any(
// feature = "stm32l4p5",
// feature = "stm32l4q5",
// feature = "stm32l4r5",
feature = "stm32l4r5",
// feature = "stm32l4s5",
// feature = "stm32l4r7",
// feature = "stm32l4s7",
Expand Down Expand Up @@ -419,7 +419,7 @@ macro_rules! cselr {
#[cfg(not(any(
// feature = "stm32l4p5",
// feature = "stm32l4q5",
// feature = "stm32l4r5",
feature = "stm32l4r5",
// feature = "stm32l4s5",
// feature = "stm32l4r7",
// feature = "stm32l4s7",
Expand Down Expand Up @@ -565,7 +565,7 @@ macro_rules! dmamux {
#[cfg(any(
// feature = "stm32l4p5",
// feature = "stm32l4q5",
// feature = "stm32l4r5",
feature = "stm32l4r5",
// feature = "stm32l4s5",
// feature = "stm32l4r7",
// feature = "stm32l4s7",
Expand All @@ -586,7 +586,7 @@ macro_rules! dmamux {
#[cfg(not(any(
// feature = "stm32l4p5",
// feature = "stm32l4q5",
// feature = "stm32l4r5",
feature = "stm32l4r5",
// feature = "stm32l4s5",
// feature = "stm32l4r7",
// feature = "stm32l4s7",
Expand Down
8 changes: 4 additions & 4 deletions src/gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -794,7 +794,7 @@ impl<const P: char> Gpio<P> {
feature = "stm32l4a6",
// feature = "stm32l4p5",
// feature = "stm32l4q5",
// feature = "stm32l4r5",
feature = "stm32l4r5",
// feature = "stm32l4s5",
// feature = "stm32l4r7",
// feature = "stm32l4s7",
Expand All @@ -812,7 +812,7 @@ impl<const P: char> Gpio<P> {
feature = "stm32l4a6",
// feature = "stm32l4p5",
// feature = "stm32l4q5",
// feature = "stm32l4r5",
feature = "stm32l4r5",
// feature = "stm32l4s5",
// feature = "stm32l4r7",
// feature = "stm32l4s7",
Expand Down
6 changes: 3 additions & 3 deletions src/i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -208,7 +208,7 @@ hal!(I2C3, i2c3);
feature = "stm32l4a6",
// feature = "stm32l4p5",
// feature = "stm32l4q5",
// feature = "stm32l4r5",
feature = "stm32l4r5",
// feature = "stm32l4s5",
// feature = "stm32l4r7",
// feature = "stm32l4s7",
Expand Down Expand Up @@ -613,7 +613,7 @@ mod stm32l4x6_pins {
#[cfg(any(
// feature = "stm32l4p5",
// feature = "stm32l4q5",
// feature = "stm32l4r5",
feature = "stm32l4r5",
// feature = "stm32l4s5",
// feature = "stm32l4r7",
// feature = "stm32l4s7",
Expand Down
11 changes: 8 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
"
Expand Down Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -152,6 +156,7 @@ pub mod pwr;
#[cfg(not(any(
feature = "stm32l433",
feature = "stm32l443",
feature = "stm32l4r5",
feature = "stm32l4r9",
feature = "stm32l4s9",
)))]
Expand Down
19 changes: 13 additions & 6 deletions src/rcc/enable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ bus! {
#[cfg(not(any(
// feature = "stm32l4p5",
// feature = "stm32l4q5",
// feature = "stm32l4r5",
feature = "stm32l4r5",
// feature = "stm32l4s5",
// feature = "stm32l4r7",
// feature = "stm32l4s7",
Expand All @@ -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",
Expand All @@ -188,7 +195,7 @@ bus! {
feature = "stm32l4a6",
// feature = "stm32l4p5",
// feature = "stm32l4q5",
// feature = "stm32l4r5",
feature = "stm32l4r5",
// feature = "stm32l4s5",
// feature = "stm32l4r7",
// feature = "stm32l4s7",
Expand Down Expand Up @@ -257,7 +264,7 @@ bus! {
feature = "stm32l443",
// feature = "stm32l4p5",
// feature = "stm32l4q5",
// feature = "stm32l4r5",
feature = "stm32l4r5",
// feature = "stm32l4s5",
// feature = "stm32l4r7",
// feature = "stm32l4s7",
Expand Down Expand Up @@ -324,7 +331,7 @@ bus! {
feature = "stm32l4a6",
// feature = "stm32l4p5",
// feature = "stm32l4q5",
// feature = "stm32l4r5",
feature = "stm32l4r5",
// feature = "stm32l4s5",
// feature = "stm32l4r7",
// feature = "stm32l4s7",
Expand Down Expand Up @@ -361,7 +368,7 @@ bus! {
#[cfg(any(
// feature = "stm32l4p5",
// feature = "stm32l4q5",
// feature = "stm32l4r5",
feature = "stm32l4r5",
// feature = "stm32l4s5",
// feature = "stm32l4r7",
// feature = "stm32l4s7",
Expand Down
10 changes: 5 additions & 5 deletions src/serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -869,7 +869,7 @@ hal! {
feature = "stm32l4a6",
// feature = "stm32l4p5",
// feature = "stm32l4q5",
// feature = "stm32l4r5",
feature = "stm32l4r5",
// feature = "stm32l4s5",
// feature = "stm32l4r7",
// feature = "stm32l4s7",
Expand All @@ -890,7 +890,7 @@ hal! {
feature = "stm32l4a6",
// feature = "stm32l4p5",
// feature = "stm32l4q5",
// feature = "stm32l4r5",
feature = "stm32l4r5",
// feature = "stm32l4s5",
// feature = "stm32l4r7",
// feature = "stm32l4s7",
Expand Down Expand Up @@ -1046,7 +1046,7 @@ impl_pin_traits! {
feature = "stm32l4a6",
// feature = "stm32l4p5",
// feature = "stm32l4q5",
// feature = "stm32l4r5",
feature = "stm32l4r5",
// feature = "stm32l4s5",
// feature = "stm32l4r7",
// feature = "stm32l4s7",
Expand Down Expand Up @@ -1074,7 +1074,7 @@ impl_pin_traits! {
feature = "stm32l4a6",
// feature = "stm32l4p5",
// feature = "stm32l4q5",
// feature = "stm32l4r5",
feature = "stm32l4r5",
// feature = "stm32l4s5",
// feature = "stm32l4r7",
// feature = "stm32l4s7",
Expand Down
8 changes: 4 additions & 4 deletions src/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ macro_rules! hal {
/// Change the baud rate of the SPI
pub fn reclock(&mut self, freq: Hertz, clocks: Clocks) {
self.spi.cr1.modify(|_, w| w.spe().clear_bit());
self.spi.cr1.modify(|_, w| {
self.spi.cr1.modify(|_, w| unsafe {
w.br().bits(Self::compute_baud_rate(clocks.$pclkX(), freq.into()));
w.spe().set_bit()
});
Expand Down Expand Up @@ -277,7 +277,7 @@ use crate::gpio::gpiod::*;
feature = "stm32l4a6",
// feature = "stm32l4p5",
// feature = "stm32l4q5",
// feature = "stm32l4r5",
feature = "stm32l4r5",
// feature = "stm32l4s5",
// feature = "stm32l4r7",
// feature = "stm32l4s7",
Expand Down Expand Up @@ -307,7 +307,7 @@ pins!(SPI1, 5,
feature = "stm32l4a6",
// feature = "stm32l4p5",
// feature = "stm32l4q5",
// feature = "stm32l4r5",
feature = "stm32l4r5",
// feature = "stm32l4s5",
// feature = "stm32l4r7",
// feature = "stm32l4s7",
Expand Down Expand Up @@ -340,7 +340,7 @@ pins!(SPI3, 6,
feature = "stm32l4a6",
// feature = "stm32l4p5",
// feature = "stm32l4q5",
// feature = "stm32l4r5",
feature = "stm32l4r5",
// feature = "stm32l4s5",
// feature = "stm32l4r7",
// feature = "stm32l4s7",
Expand Down
2 changes: 1 addition & 1 deletion src/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions src/watchdog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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));
}
Expand Down

0 comments on commit 9d1767e

Please sign in to comment.