Skip to content

Commit b5f8ac2

Browse files
committed
g4/f3/f0 init
1 parent d058a22 commit b5f8ac2

39 files changed

+3727
-403
lines changed

.lapce/settings.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[lapce-rust]
22
check.allTargets = false
33
check.targets = "thumbv7em-none-eabihf"
4-
cargo.features = ["rtic", "stm32f745"]
4+
cargo.features = ["rtic", "stm32l475"]

Cargo.toml

Lines changed: 99 additions & 45 deletions
Large diffs are not rendered by default.

src/adc/l4.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@
33
use core::{
44
convert::Infallible,
55
marker::PhantomData,
6-
ops::DerefMut,
7-
sync::atomic::{self, Ordering},
6+
//ops::DerefMut,
7+
//sync::atomic::{self, Ordering},
88
};
9-
9+
#[cfg(feature = "dma")]
1010
use stable_deref_trait::StableDeref;
1111

12+
#[cfg(feature = "dma")]
1213
use crate::{
1314
dma::{dma1, Event as DMAEvent, RxDma, Transfer, TransferPayload, W},
1415
dmamux::{DmaInput, DmaMux},
16+
};
17+
use crate::{
1518
gpio::{self, Analog},
1619
hal::{
1720
adc::{Channel as EmbeddedHalChannel, OneShot},
@@ -279,6 +282,7 @@ where
279282
}
280283
}
281284

285+
#[cfg(feature = "dma")]
282286
impl TransferPayload for RxDma<Adc<ADC1>, dma1::C1> {
283287
fn start(&mut self) {
284288
self.channel.start();
@@ -289,13 +293,15 @@ impl TransferPayload for RxDma<Adc<ADC1>, dma1::C1> {
289293
}
290294
}
291295

296+
#[cfg(feature = "dma")]
292297
impl RxDma<Adc<ADC1>, dma1::C1> {
293298
pub fn split(mut self) -> (Adc<ADC1>, dma1::C1) {
294299
self.stop();
295300
(self.payload, self.channel)
296301
}
297302
}
298303

304+
#[cfg(feature = "dma")]
299305
impl<BUFFER, const N: usize> Transfer<W, BUFFER, RxDma<Adc<ADC1>, dma1::C1>>
300306
where
301307
BUFFER: Sized + StableDeref<Target = [u16; N]> + DerefMut + 'static,
@@ -675,15 +681,7 @@ macro_rules! adc {
675681
delay: &mut impl DelayUs<u32>,
676682
) -> Self {
677683
// Select system clock as ADC clock source
678-
ccipr.ccipr().modify(|_, w| {
679-
// This is sound, as `0b11` is a valid value for this field.
680-
unsafe {
681-
// TODO: Switch to enum once https://github.com/stm32-rs/stm32-rs/pull/720 is released.
682-
w.adcsel().bits(0b11);
683-
}
684-
685-
w
686-
});
684+
ccipr.ccipr().modify(|_, w| w.adcsel().sysclk());
687685

688686
// Initialize the ADC, according to the STM32L4xx Reference Manual,
689687
// section 16.4.6.

src/dma/traits.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,22 +293,22 @@ pub use f3::*;
293293
mod f4;
294294
#[cfg(feature = "f4")]
295295
pub use f4::*;
296-
/*
296+
297297
#[cfg(feature = "f7")]
298298
mod f7;
299299
#[cfg(feature = "f7")]
300300
pub use f7::*;
301-
301+
/*
302302
#[cfg(feature = "g0")]
303303
mod g0;
304304
#[cfg(feature = "g0")]
305305
pub use g0::*;
306-
306+
*/
307307
#[cfg(feature = "g4")]
308308
mod g4;
309309
#[cfg(feature = "g4")]
310310
pub use g4::*;
311-
311+
/*
312312
#[cfg(feature = "h7")]
313313
mod h7;
314314
#[cfg(feature = "h7")]

src/dma/traits/f7.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

src/dma/traits/g4.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

src/gpio/alt.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -514,11 +514,11 @@ pub trait QuadSpiBanks {
514514
}
515515
#[cfg(feature = "quadspi")]
516516
pub trait QuadSpiBank {
517-
type Io0;
518-
type Io1;
519-
type Io2;
520-
type Io3;
521-
type Ncs;
517+
type Io0: crate::gpio::PinSpeed;
518+
type Io1: crate::gpio::PinSpeed;
519+
type Io2: crate::gpio::PinSpeed;
520+
type Io3: crate::gpio::PinSpeed;
521+
type Ncs: crate::gpio::PinSpeed;
522522
}
523523

524524
// SAI pins

src/gpio/alt/c0.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
use super::*;
2-
use crate::gpio::{self, Edge, ExtiPin};
3-
use crate::gpio::{marker, Alternate, NoPin, OpenDrain, PinMode, PushPull};
4-
use crate::pac::EXTI;
5-
use crate::syscfg::SysCfg;
2+
use crate::gpio::{self, NoPin, OpenDrain, PushPull};
63

74
pub mod debug {
85
use super::*;

src/gpio/alt/f0.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
use super::*;
2+
use crate::gpio::{self, NoPin, OpenDrain, PushPull};
3+
14
#[cfg(any(feature = "gpio-f042", feature = "gpio-f052", feature = "gpio-f091"))]
25
pub mod can {
36
use super::*;

src/gpio/alt/f2.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
use super::*;
2-
use crate::gpio::{self, Edge, ExtiPin};
3-
use crate::gpio::{marker, Alternate, NoPin, OpenDrain, PinMode, PushPull};
4-
use crate::pac::EXTI;
5-
use crate::syscfg::SysCfg;
2+
use crate::gpio::{self, NoPin, OpenDrain, PushPull};
63

74
pub mod can1 {
85
use super::*;

src/gpio/alt/f3.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
use super::*;
2-
use crate::gpio::{self, Edge, ExtiPin};
3-
use crate::gpio::{marker, Alternate, NoPin, OpenDrain, PinMode, PushPull};
4-
use crate::pac::EXTI;
5-
use crate::syscfg::SysCfg;
2+
use crate::gpio::{self, NoPin, OpenDrain, PushPull};
63

74
pub mod can {
85
use super::*;

src/gpio/alt/f7.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
use super::*;
2-
use crate::gpio::{self, Edge, ExtiPin};
3-
use crate::gpio::{marker, Alternate, NoPin, OpenDrain, PinMode, PushPull};
4-
use crate::pac::EXTI;
5-
use crate::syscfg::SysCfg;
2+
use crate::gpio::{self, NoPin, OpenDrain, PushPull};
63

74
pub mod can1 {
85
use super::*;

src/gpio/alt/g0.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
use super::*;
2-
use crate::gpio::{self, Edge, ExtiPin};
3-
use crate::gpio::{marker, Alternate, NoPin, OpenDrain, PinMode, PushPull};
4-
use crate::pac::EXTI;
5-
use crate::syscfg::SysCfg;
2+
use crate::gpio::{self, NoPin, OpenDrain, PushPull};
63

74
#[cfg(any(feature = "gpio-g05x", feature = "gpio-g07x", feature = "gpio-g0bx"))]
85
pub mod comp1 {

src/gpio/alt/g4.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
use super::*;
2-
use crate::gpio::{self, Edge, ExtiPin};
3-
use crate::gpio::{marker, Alternate, NoPin, OpenDrain, PinMode, PushPull};
4-
use crate::pac::EXTI;
5-
use crate::syscfg::SysCfg;
2+
use crate::gpio::{self, NoPin, OpenDrain, PushPull};
63

74
pub mod comp1 {
85
use super::*;
@@ -870,7 +867,9 @@ pub mod lptim1 {
870867

871868
PC2<1>,
872869
],
870+
}
873871

872+
pin! {
874873
<Out> default:PushPull for [
875874
PA14<1>,
876875

@@ -1181,7 +1180,7 @@ pub mod sai1 {
11811180
PF6<3>,
11821181
],
11831182
}
1184-
use crate::pac::SAI1 as SAI;
1183+
use crate::pac::SAI;
11851184
pub struct ChannelA;
11861185
pub struct ChannelB;
11871186
impl SaiChannels for SAI {

src/gpio/alt/h7.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
use super::*;
2-
use crate::gpio::{self, Edge, ExtiPin};
3-
use crate::gpio::{marker, Alternate, NoPin, OpenDrain, PinMode, PushPull};
4-
use crate::pac::EXTI;
5-
use crate::syscfg::SysCfg;
2+
use crate::gpio::{self, NoPin, OpenDrain, PushPull};
63

74
/*#[cfg(feature = "gpio-h747")]
85
pub mod comp {

src/gpio/alt/l0.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
use super::*;
2-
use crate::gpio::{self, Edge, ExtiPin};
3-
use crate::gpio::{marker, Alternate, NoPin, OpenDrain, PinMode, PushPull};
4-
use crate::pac::EXTI;
5-
use crate::syscfg::SysCfg;
2+
use crate::gpio::{self, NoPin, OpenDrain, PushPull};
63

74
pub mod comp1 {
85
use super::*;

src/gpio/alt/l1.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
use super::*;
2-
use crate::gpio::{self, Edge, ExtiPin};
3-
use crate::gpio::{marker, Alternate, NoPin, OpenDrain, PinMode, PushPull};
4-
use crate::pac::EXTI;
5-
use crate::syscfg::SysCfg;
2+
use crate::gpio::{self, NoPin, OpenDrain, PushPull};
63

74
#[cfg(feature = "gpio-l162xe")]
85
pub mod comp1 {

src/gpio/alt/l4.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
use super::*;
2-
use crate::gpio::{self, Edge, ExtiPin};
3-
use crate::gpio::{marker, Alternate, NoPin, OpenDrain, PinMode, PushPull};
4-
use crate::pac::EXTI;
5-
use crate::syscfg::SysCfg;
2+
use crate::gpio::{self, NoPin, OpenDrain, PushPull};
63

74
#[cfg(any(
85
feature = "gpio-l43x",

src/gpio/alt/l4p.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
use super::*;
2-
use crate::gpio::{self, Edge, ExtiPin};
3-
use crate::gpio::{marker, Alternate, NoPin, OpenDrain, PinMode, PushPull};
4-
use crate::pac::EXTI;
5-
use crate::syscfg::SysCfg;
2+
use crate::gpio::{self, NoPin, OpenDrain, PushPull};
63

74
pub mod can1 {
85
use super::*;

src/gpio/alt/l5.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
use super::*;
2-
use crate::gpio::{self, Edge, ExtiPin};
3-
use crate::gpio::{marker, Alternate, NoPin, OpenDrain, PinMode, PushPull};
4-
use crate::pac::EXTI;
5-
use crate::syscfg::SysCfg;
2+
use crate::gpio::{self, NoPin, OpenDrain, PushPull};
63

74
pub mod comp1 {
85
use super::*;

src/gpio/alt/u5.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
use super::*;
2-
use crate::gpio::{self, Edge, ExtiPin};
3-
use crate::gpio::{marker, Alternate, NoPin, OpenDrain, PinMode, PushPull};
4-
use crate::pac::EXTI;
5-
use crate::syscfg::SysCfg;
2+
use crate::gpio::{self, NoPin, OpenDrain, PushPull};
63

74
/*pub mod adf1 {
85
use super::*;

src/gpio/alt/wb.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
use super::*;
2-
use crate::gpio::{self, Edge, ExtiPin};
3-
use crate::gpio::{marker, Alternate, NoPin, OpenDrain, PinMode, PushPull};
4-
use crate::pac::EXTI;
5-
use crate::syscfg::SysCfg;
2+
use crate::gpio::{self, NoPin, OpenDrain, PushPull};
63

74
/*pub mod cm4 {
85
use super::*;

src/gpio/alt/wl.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
use super::*;
2-
use crate::gpio::{self, Edge, ExtiPin};
3-
use crate::gpio::{marker, Alternate, NoPin, OpenDrain, PinMode, PushPull};
4-
use crate::pac::EXTI;
5-
use crate::syscfg::SysCfg;
2+
use crate::gpio::{self, NoPin, OpenDrain, PushPull};
63

74
/*pub mod cm4 {
85
use super::*;

src/gpio/exti.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,23 +85,23 @@ where
8585
Edge::Rising => {
8686
#[cfg(any(feature = "f4", feature = "f7"))]
8787
let (rtsr, ftsr) = (&exti.rtsr, &exti.ftsr);
88-
#[cfg(feature = "l4")]
88+
#[cfg(any(feature = "f3", feature = "g4", feature = "l4"))]
8989
let (rtsr, ftsr) = (&exti.rtsr1, &exti.ftsr1);
9090
rtsr.modify(|r, w| unsafe { w.bits(r.bits() | (1 << i)) });
9191
ftsr.modify(|r, w| unsafe { w.bits(r.bits() & !(1 << i)) });
9292
}
9393
Edge::Falling => {
9494
#[cfg(any(feature = "f4", feature = "f7"))]
9595
let (rtsr, ftsr) = (&exti.rtsr, &exti.ftsr);
96-
#[cfg(feature = "l4")]
96+
#[cfg(any(feature = "f3", feature = "g4", feature = "l4"))]
9797
let (rtsr, ftsr) = (&exti.rtsr1, &exti.ftsr1);
9898
ftsr.modify(|r, w| unsafe { w.bits(r.bits() | (1 << i)) });
9999
rtsr.modify(|r, w| unsafe { w.bits(r.bits() & !(1 << i)) });
100100
}
101101
Edge::RisingFalling => {
102102
#[cfg(any(feature = "f4", feature = "f7"))]
103103
let (rtsr, ftsr) = (&exti.rtsr, &exti.ftsr);
104-
#[cfg(feature = "l4")]
104+
#[cfg(any(feature = "f3", feature = "g4", feature = "l4"))]
105105
let (rtsr, ftsr) = (&exti.rtsr1, &exti.ftsr1);
106106
rtsr.modify(|r, w| unsafe { w.bits(r.bits() | (1 << i)) });
107107
ftsr.modify(|r, w| unsafe { w.bits(r.bits() | (1 << i)) });
@@ -113,7 +113,7 @@ where
113113
fn enable_interrupt(&mut self, exti: &mut EXTI) {
114114
#[cfg(any(feature = "f4", feature = "f7"))]
115115
let imr = &exti.imr;
116-
#[cfg(feature = "l4")]
116+
#[cfg(any(feature = "f3", feature = "g4", feature = "l4"))]
117117
let imr = &exti.imr1;
118118
imr.modify(|r, w| unsafe { w.bits(r.bits() | (1 << self.pin_id())) });
119119
}
@@ -122,7 +122,7 @@ where
122122
fn disable_interrupt(&mut self, exti: &mut EXTI) {
123123
#[cfg(any(feature = "f4", feature = "f7"))]
124124
let imr = &exti.imr;
125-
#[cfg(feature = "l4")]
125+
#[cfg(any(feature = "f3", feature = "g4", feature = "l4"))]
126126
let imr = &exti.imr1;
127127
imr.modify(|r, w| unsafe { w.bits(r.bits() & !(1 << self.pin_id())) });
128128
}
@@ -131,7 +131,7 @@ where
131131
fn clear_interrupt_pending_bit(&mut self) {
132132
#[cfg(any(feature = "f4", feature = "f7"))]
133133
let pr = unsafe { &(*EXTI::ptr()).pr };
134-
#[cfg(feature = "l4")]
134+
#[cfg(any(feature = "f3", feature = "g4", feature = "l4"))]
135135
let pr = unsafe { &(*EXTI::ptr()).pr1 };
136136
pr.write(|w| unsafe { w.bits(1 << self.pin_id()) });
137137
}
@@ -140,7 +140,7 @@ where
140140
fn check_interrupt(&self) -> bool {
141141
#[cfg(any(feature = "f4", feature = "f7"))]
142142
let pr = unsafe { &(*EXTI::ptr()).pr };
143-
#[cfg(feature = "l4")]
143+
#[cfg(any(feature = "f3", feature = "g4", feature = "l4"))]
144144
let pr = unsafe { &(*EXTI::ptr()).pr1 };
145145
(pr.read().bits() & (1 << self.pin_id())) != 0
146146
}

src/i2c/l4.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
use crate::hal::blocking::i2c::{Read, Write, WriteRead};
66
use crate::rcc::{Clocks, Enable, Reset};
77
use crate::time::Hertz;
8-
use crate::{
9-
gpio,
10-
pac::{self, i2c1},
11-
};
8+
use crate::{gpio, pac};
129
use core::ops::Deref;
1310

1411
/// I2C error

0 commit comments

Comments
 (0)