Skip to content

Commit 469a51a

Browse files
authored
Merge pull request #47 from lthiery/enable-spi2
Add SPI2, LPUART, and I2C definitions for stm32l0x2/3
2 parents e324f19 + d2618e3 commit 469a51a

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ features = ["stm32l0x1", "rt"]
2929
[dependencies]
3030
as-slice = "0.1.0"
3131
embedded-hal = { version = "0.2.3", features = ["unproven"] }
32-
cortex-m = {version = "0.6.0", features = ["const-fn"] }
32+
cortex-m = {version = "0.6.1", features = ["const-fn"] }
3333
cortex-m-rt = "0.6.8"
3434
cortex-m-semihosting = "0.3.2"
3535
void = { version = "1.0.2", default-features = false }

src/i2c.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ use crate::pac::{
2929
i2c1::{
3030
RegisterBlock,
3131
cr2::RD_WRNW,
32-
},
33-
I2C1,
32+
}
3433
};
34+
pub use crate::pac::I2C1;
3535
use crate::rcc::Rcc;
3636
use crate::time::Hertz;
3737
use cast::u8;

src/serial.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ impl_pins!(
170170
#[cfg(any(feature = "stm32l0x2", feature = "stm32l0x3"))]
171171
impl_pins!(
172172
LPUART1, PA2, PA3, AF6;
173+
LPUART1, PB10, PB11, AF4;
174+
LPUART1, PB11, PB10, AF7;
173175
USART1, PA9, PA10, AF4;
174176
USART1, PB6, PB7, AF0;
175177
USART2, PA2, PA3, AF4;

src/spi.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ use crate::gpio::gpiob::*;
55
use crate::gpio::{AltMode, Floating, Input};
66
use crate::hal;
77
use crate::pac::SPI1;
8+
#[cfg(any(feature = "stm32l0x2", feature = "stm32l0x3"))]
9+
use crate::pac::SPI2;
810
use crate::rcc::Rcc;
911
use crate::time::Hertz;
1012
use core::ptr;
@@ -122,6 +124,23 @@ pins! {
122124
]
123125
}
124126

127+
#[cfg(any(feature = "stm32l0x2", feature = "stm32l0x3"))]
128+
pins! {
129+
SPI2:
130+
SCK: [
131+
[NoSck, None],
132+
[PB13<Input<Floating>>, AltMode::AF0]
133+
]
134+
MISO: [
135+
[NoMiso, None],
136+
[PB14<Input<Floating>>, AltMode::AF0]
137+
]
138+
MOSI: [
139+
[NoMosi, None],
140+
[PB15<Input<Floating>>, AltMode::AF0]
141+
]
142+
}
143+
125144
#[cfg(feature = "stm32l0x1")]
126145
pins! {
127146
SPI1:
@@ -293,3 +312,8 @@ macro_rules! spi {
293312
spi! {
294313
SPI1: (spi1, apb2enr, spi1en, apb2_clk),
295314
}
315+
316+
#[cfg(any(feature = "stm32l0x2", feature = "stm32l0x3"))]
317+
spi! {
318+
SPI2: (spi2, apb1enr, spi2en, apb1_clk),
319+
}

0 commit comments

Comments
 (0)