Skip to content

Commit 2e3669f

Browse files
feat: add i2c2 channel to stm32c071 microcontrollers
1 parent b922477 commit 2e3669f

File tree

4 files changed

+57
-0
lines changed

4 files changed

+57
-0
lines changed

src/exti.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ pub enum Event {
2323
GPIO15 = 15,
2424
RTC = 19,
2525
I2C1 = 23,
26+
#[cfg(feature = "stm32c071")]
27+
I2C2 = 24,
2628
USART1 = 25,
2729
LSE_CSS = 31,
2830
}

src/i2c/blocking.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ use crate::rcc::*;
66
use crate::stm32::I2C;
77
use hal::blocking::i2c::{Read, Write, WriteRead};
88

9+
#[cfg(feature = "stm32c071")]
10+
use crate::stm32::I2C2;
11+
912
pub trait I2cSlave {
1013
/// Enable/Disable Slave Byte Control. Default SBC is switched on.
1114
/// For master write/read the transaction should start with sbc disabled.
@@ -521,3 +524,25 @@ i2c!(
521524
(PB7<Output<OpenDrain>>, AltFunction::AF14),
522525
],
523526
);
527+
528+
#[cfg(feature = "stm32c071")]
529+
i2c!(
530+
I2C2,
531+
i2c2,
532+
sda: [
533+
(PA6<Output<OpenDrain>>, AltFunction::AF6),
534+
(PA12<Output<OpenDrain>>, AltFunction::AF6),
535+
(PA10<Output<OpenDrain>>, AltFunction::AF8),
536+
(PB4<Output<OpenDrain>>, AltFunction::AF6),
537+
(PB11<Output<OpenDrain>>, AltFunction::AF6),
538+
(PB14<Output<OpenDrain>>, AltFunction::AF6),
539+
],
540+
scl: [
541+
(PA7<Output<OpenDrain>>, AltFunction::AF6),
542+
(PA11<Output<OpenDrain>>, AltFunction::AF6),
543+
(PA9<Output<OpenDrain>>, AltFunction::AF8),
544+
(PB3<Output<OpenDrain>>, AltFunction::AF5),
545+
(PB10<Output<OpenDrain>>, AltFunction::AF6),
546+
(PB13<Output<OpenDrain>>, AltFunction::AF6),
547+
],
548+
);

src/i2c/nonblocking.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ use crate::rcc::*;
77
use crate::stm32::I2C;
88
use nb::Error::{Other, WouldBlock};
99

10+
#[cfg(feature = "stm32c071")]
11+
use crate::stm32::I2C2;
12+
1013
pub trait I2cControl {
1114
/// Start listening for an interrupt event, will also enable non_blocking mode
1215
fn listen(&mut self);
@@ -604,3 +607,25 @@ i2c!(
604607
(PB7<Output<OpenDrain>>, AltFunction::AF14),
605608
],
606609
);
610+
611+
#[cfg(feature = "stm32c071")]
612+
i2c!(
613+
I2C2,
614+
i2c2,
615+
sda: [
616+
(PA6<Output<OpenDrain>>, AltFunction::AF6),
617+
(PA12<Output<OpenDrain>>, AltFunction::AF6),
618+
(PA10<Output<OpenDrain>>, AltFunction::AF8),
619+
(PB4<Output<OpenDrain>>, AltFunction::AF6),
620+
(PB11<Output<OpenDrain>>, AltFunction::AF6),
621+
(PB14<Output<OpenDrain>>, AltFunction::AF6),
622+
],
623+
scl: [
624+
(PA7<Output<OpenDrain>>, AltFunction::AF6),
625+
(PA11<Output<OpenDrain>>, AltFunction::AF6),
626+
(PA9<Output<OpenDrain>>, AltFunction::AF8),
627+
(PB3<Output<OpenDrain>>, AltFunction::AF5),
628+
(PB10<Output<OpenDrain>>, AltFunction::AF6),
629+
(PB13<Output<OpenDrain>>, AltFunction::AF6),
630+
],
631+
);

src/rcc/enable.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,8 @@ bus! {
137137
GPIOD => (IOP, gpioden, gpiodsmen, gpiodrst), // 3
138138
GPIOF => (IOP, gpiofen, gpiofsmen, gpiofrst), // 5
139139
}
140+
141+
#[cfg(feature = "stm32c071")]
142+
bus! {
143+
I2C2 => (APB1, i2c2en, i2c2smen, i2c2rst), // 21
144+
}

0 commit comments

Comments
 (0)