Skip to content

Commit 4692256

Browse files
committed
fix
1 parent eb90692 commit 4692256

File tree

10 files changed

+152
-55
lines changed

10 files changed

+152
-55
lines changed

Cargo.toml

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,12 @@ document-features = "0.2"
6666
micromath = { version = "2.1.0", optional = true }
6767

6868
[dependencies.stm32f4]
69-
package = "stm32f4-staging"
70-
version = "0.19.0"
69+
git = "https://github.com/stm32-rs/stm32-rs-nightlies"
7170
features = ["atomics"]
7271
optional = true
7372

7473
[dependencies.stm32f7]
75-
package = "stm32f7-staging"
76-
version = "0.16.0"
74+
git = "https://github.com/stm32-rs/stm32-rs-nightlies"
7775
features = ["atomics"]
7876
optional = true
7977

@@ -100,7 +98,7 @@ version = "0.5.0"
10098
optional = true
10199

102100
[dev-dependencies]
103-
defmt = "0.3.4"
101+
defmt = "1.0"
104102
defmt-rtt = "0.4.0"
105103
panic-probe = { version = "0.3.2", features = ["print-defmt"] }
106104
panic-semihosting = "0.6.0"
@@ -613,29 +611,35 @@ gpio-f469 = [
613611

614612
# F7
615613

616-
stm32f722 = ["svd-f7x2"]
617-
stm32f723 = ["svd-f7x3", "usb_hs_phy"]
618-
stm32f730 = ["svd-f730", "usb_hs_phy"]
619-
stm32f732 = ["svd-f7x2"]
620-
stm32f733 = ["svd-f7x3", "usb_hs_phy"]
614+
stm32f722 = ["svd-f722"]
615+
stm32f723 = ["svd-f723"]
616+
stm32f730 = ["svd-f730"]
617+
stm32f732 = ["svd-f732"]
618+
stm32f733 = ["svd-f733"]
621619
stm32f745 = ["svd-f745"]
622-
stm32f746 = ["svd-f7x6"]
623-
stm32f756 = ["svd-f7x6"]
620+
stm32f746 = ["svd-f746"]
621+
stm32f756 = ["svd-f756"]
624622
stm32f765 = ["svd-f765"]
625-
stm32f767 = ["svd-f7x7"]
626-
stm32f769 = ["svd-f7x9"]
627-
stm32f777 = ["svd-f7x7"]
628-
stm32f778 = ["svd-f7x9"]
629-
stm32f779 = ["svd-f7x9"]
630-
631-
svd-f7x2 = ["f7", "stm32f7?/stm32f7x2", "gpio-f72x"]
632-
svd-f7x3 = ["f7", "stm32f7?/stm32f7x3", "gpio-f72x"]
633-
svd-f730 = ["f7", "stm32f7?/stm32f730", "gpio-f72x"]
623+
stm32f767 = ["svd-f767"]
624+
stm32f769 = ["svd-f769"]
625+
stm32f777 = ["svd-f777"]
626+
stm32f778 = ["svd-f778"]
627+
stm32f779 = ["svd-f779"]
628+
629+
svd-f722 = ["f7", "stm32f7?/stm32f722", "gpio-f72x"]
630+
svd-f723 = ["f7", "stm32f7?/stm32f723", "gpio-f72x", "usb_hs_phy"]
631+
svd-f732 = ["f7", "stm32f7?/stm32f732", "gpio-f72x"]
632+
svd-f733 = ["f7", "stm32f7?/stm32f733", "gpio-f72x", "usb_hs_phy"]
633+
svd-f730 = ["f7", "stm32f7?/stm32f730", "gpio-f72x", "usb_hs_phy"]
634634
svd-f745 = ["f7", "stm32f7?/stm32f745", "gpio-f746"]
635-
svd-f7x6 = ["f7", "stm32f7?/stm32f7x6", "gpio-f746"]
635+
svd-f746 = ["f7", "stm32f7?/stm32f746", "gpio-f746"]
636+
svd-f756 = ["f7", "stm32f7?/stm32f756", "gpio-f746"]
636637
svd-f765 = ["f7", "stm32f7?/stm32f765", "gpio-f76x"]
637-
svd-f7x7 = ["f7", "stm32f7?/stm32f7x7", "gpio-f76x"]
638-
svd-f7x9 = ["f7", "stm32f7?/stm32f7x9", "gpio-f76x"]
638+
svd-f767 = ["f7", "stm32f7?/stm32f767", "gpio-f76x"]
639+
svd-f769 = ["f7", "stm32f7?/stm32f769", "gpio-f76x"]
640+
svd-f777 = ["f7", "stm32f7?/stm32f777", "gpio-f76x"]
641+
svd-f778 = ["f7", "stm32f7?/stm32f778", "gpio-f76x"]
642+
svd-f779 = ["f7", "stm32f7?/stm32f779", "gpio-f76x"]
639643

640644
gpio-f72x = [
641645
"adc2",

src/dsi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ impl DsiHost {
244244
/ odf;
245245
let f_pix_khz = f_phy_hz / 1_000 / 8;
246246
let uix4 = 4_000_000_000 / f_phy_hz;
247-
dsi.wpcr0()
247+
dsi.wpcr1()
248248
.modify(|_, w| unsafe { w.uix4().bits(uix4 as u8) });
249249

250250
match dsi_config.interrupts {

src/lib.rs

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,31 +59,54 @@ pub use stm32f4::stm32f446 as pac;
5959
/// Re-export of the [svd2rust](https://crates.io/crates/svd2rust) auto-generated API for the stm32f469/f479 peripherals.
6060
pub use stm32f4::stm32f469 as pac;
6161

62-
#[cfg(feature = "svd-f7x2")]
63-
pub use stm32f7::stm32f7x2 as pac;
62+
#[cfg(feature = "svd-f722")]
63+
pub use stm32f7::stm32f722 as pac;
6464

65-
#[cfg(feature = "svd-f7x3")]
66-
pub use stm32f7::stm32f7x3 as pac;
65+
#[cfg(feature = "svd-f723")]
66+
pub use stm32f7::stm32f723 as pac;
67+
68+
#[cfg(feature = "svd-f732")]
69+
pub use stm32f7::stm32f732 as pac;
70+
71+
#[cfg(feature = "svd-f733")]
72+
pub use stm32f7::stm32f733 as pac;
6773

6874
#[cfg(feature = "svd-f730")]
6975
pub use stm32f7::stm32f730 as pac;
7076

7177
#[cfg(feature = "svd-f745")]
7278
pub use stm32f7::stm32f745 as pac;
7379

74-
#[cfg(feature = "svd-f7x6")]
75-
pub use stm32f7::stm32f7x6 as pac;
80+
#[cfg(feature = "svd-f746")]
81+
pub use stm32f7::stm32f746 as pac;
82+
83+
#[cfg(feature = "svd-f756")]
84+
pub use stm32f7::stm32f756 as pac;
7685

7786
#[cfg(feature = "svd-f765")]
7887
pub use stm32f7::stm32f765 as pac;
7988

80-
#[cfg(feature = "svd-f7x7")]
81-
pub use stm32f7::stm32f7x7 as pac;
89+
#[cfg(feature = "svd-f767")]
90+
pub use stm32f7::stm32f767 as pac;
91+
92+
#[cfg(feature = "svd-f769")]
93+
pub use stm32f7::stm32f769 as pac;
94+
95+
#[cfg(feature = "svd-f777")]
96+
pub use stm32f7::stm32f777 as pac;
8297

83-
#[cfg(feature = "svd-f7x9")]
84-
pub use stm32f7::stm32f7x9 as pac;
98+
#[cfg(feature = "svd-f778")]
99+
pub use stm32f7::stm32f778 as pac;
100+
101+
#[cfg(feature = "svd-f779")]
102+
pub use stm32f7::stm32f779 as pac;
103+
104+
#[cfg(feature = "f4")]
85105
use stm32f4::Periph;
86106

107+
#[cfg(feature = "f7")]
108+
use stm32f7::Periph;
109+
87110
// Enable use of interrupt macro
88111
pub use crate::pac::interrupt;
89112

src/pacext.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1+
#[cfg(feature = "f4")]
12
use stm32f4::{Readable, Reg, RegisterSpec, Resettable, Writable, R, W};
23

34
#[cfg(feature = "f4")]
5+
#[path = "./pacext/uart_v2.rs"]
46
pub mod uart;
57

68
#[cfg(feature = "f7")]
7-
pub mod uart {
8-
use core::ops::Deref;
9-
10-
pub trait UartExt: Deref<crate::pac::usart1::RegisterBlock> {}
11-
impl<U> UartExt for U where U: Deref<crate::pac::usart1::RegisterBlock> {}
12-
}
9+
#[path = "./pacext/uart_v3.rs"]
10+
pub mod uart;
1311

1412
macro_rules! wrap_r {
1513
(pub trait $TrR:ident {

src/pacext/uart_v3.rs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
use crate::{sealed, Sealed};
2+
3+
use super::*;
4+
use crate::pac::usart1;
5+
6+
pub trait UartRB: Sealed {
7+
fn cr1(&self) -> &usart1::CR1;
8+
fn rdr(&self) -> &usart1::RDR;
9+
fn tdr(&self) -> &usart1::TDR;
10+
fn brr(&self) -> &usart1::BRR;
11+
fn icr(&self) -> &usart1::ICR;
12+
fn isr(&self) -> &usart1::ISR;
13+
fn cr2(&self) -> &usart1::CR2;
14+
fn cr3(&self) -> &usart1::CR3;
15+
fn gtpr(&self) -> &usart1::GTPR;
16+
}
17+
18+
impl Sealed for usart1::RegisterBlock {}
19+
impl UartRB for usart1::RegisterBlock {
20+
fn cr1(&self) -> &usart1::CR1 {
21+
self.cr1()
22+
}
23+
24+
fn rdr(&self) -> &usart1::RDR {
25+
self.rdr()
26+
}
27+
28+
fn tdr(&self) -> &usart1::TDR {
29+
self.tdr()
30+
}
31+
32+
fn brr(&self) -> &usart1::BRR {
33+
self.brr()
34+
}
35+
36+
fn icr(&self) -> &usart1::ICR {
37+
self.icr()
38+
}
39+
40+
fn isr(&self) -> &usart1::ISR {
41+
self.isr()
42+
}
43+
44+
fn cr2(&self) -> &usart1::CR2 {
45+
self.cr2()
46+
}
47+
48+
fn cr3(&self) -> &usart1::CR3 {
49+
self.cr3()
50+
}
51+
52+
fn gtpr(&self) -> &usart1::GTPR {
53+
self.gtpr()
54+
}
55+
}

src/rcc/f7/enable.rs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ macro_rules! bus_reset {
7676
macro_rules! bus {
7777
($($PER:ident => ($busX:ty, $($en:ident)?, $($lpen:ident)?, $($rst:ident)?),)+) => {
7878
$(
79-
impl crate::Sealed for crate::pac::$PER {}
8079
impl RccBus for crate::pac::$PER {
8180
type Bus = $busX;
8281
}
@@ -155,7 +154,13 @@ bus! {
155154
SAI2 => (APB2, sai2en, sai2lpen, sai2rst), // 23
156155
}
157156

158-
#[cfg(any(feature = "svd-f730", feature = "svd-f7x2", feature = "svd-f7x3",))]
157+
#[cfg(any(
158+
feature = "svd-f730",
159+
feature = "svd-f722",
160+
feature = "svd-f723",
161+
feature = "svd-f732",
162+
feature = "svd-f733",
163+
))]
159164
bus! {
160165
AES => (AHB2, aesen, aeslpen, aesrst), // 4
161166

@@ -166,10 +171,13 @@ bus! {
166171
#[cfg(any(
167172
feature = "svd-f745",
168173
//feature = "svd-f750",
169-
feature = "svd-f7x6",
174+
feature = "svd-f746",
175+
feature = "svd-f756",
170176
feature = "svd-f765",
171-
feature = "svd-f7x7",
172-
feature = "svd-f7x9",
177+
feature = "svd-f767",
178+
feature = "svd-f777",
179+
feature = "svd-f769",
180+
feature = "svd-f779",
173181
))]
174182
bus! {
175183
GPIOJ => (AHB1, gpiojen, gpiojlpen, gpiojrst), // 9
@@ -190,7 +198,13 @@ bus! {
190198
LTDC => (APB2, ltdcen, ltdclpen, ltdcrst), // 26
191199
}
192200

193-
#[cfg(any(feature = "svd-f765", feature = "svd-f7x7", feature = "svd-f7x9"))]
201+
#[cfg(any(
202+
feature = "svd-f765",
203+
feature = "svd-f767",
204+
feature = "svd-f777",
205+
feature = "svd-f769",
206+
feature = "svd-f779"
207+
))]
194208
bus! {
195209
JPEG => (AHB2, jpegen, jpeglpen,), // 1
196210

src/serial.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ pub enum Error {
6363
#[enumflags2::bitflags]
6464
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
6565
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
66-
#[repr(u16)]
66+
#[cfg_attr(feature = "f4", repr(u16))]
67+
#[cfg_attr(feature = "f7", repr(u32))]
6768
pub enum Event {
6869
/// IDLE interrupt enable
6970
Idle = 1 << 4,
@@ -81,7 +82,8 @@ pub enum Event {
8182
#[enumflags2::bitflags]
8283
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
8384
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
84-
#[repr(u16)]
85+
#[cfg_attr(feature = "f4", repr(u16))]
86+
#[cfg_attr(feature = "f7", repr(u32))]
8587
pub enum Flag {
8688
/// Parity error
8789
ParityError = 1 << 0,
@@ -109,7 +111,8 @@ pub enum Flag {
109111
#[enumflags2::bitflags]
110112
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
111113
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
112-
#[repr(u16)]
114+
#[cfg_attr(feature = "f4", repr(u16))]
115+
#[cfg_attr(feature = "f7", repr(u32))]
113116
pub enum CFlag {
114117
/// Read data register not empty
115118
RxNotEmpty = 1 << 5,
@@ -292,7 +295,7 @@ impl<USART: Instance, WORD> Serial<USART, WORD> {
292295
calculate_brr(pclk_freq, baud)?
293296
};
294297

295-
uart.brr().write(|w| unsafe { w.bits(div as u16) });
298+
uart.brr().write(|w| unsafe { w.bits(div as _) });
296299

297300
// Reset other registers to disable advanced USART features
298301
uart.cr2().reset();

src/serial/uart_impls.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,13 @@ pub trait RegisterBlockImpl: UartRB {
167167
self.icr().write(|w| unsafe { w.bits(flags.bits()) });
168168
}
169169
fn clear_idle_interrupt(&self) {
170-
let _ = self.sr().read();
171-
let _ = self.dr().read();
172170
#[cfg(feature = "uart_v2")]
173171
{
174172
let _ = self.sr().read();
175173
let _ = self.dr().read();
176174
}
177175
#[cfg(feature = "uart_v3")]
178-
self.icr().write(|w| w.idlecf().set_bit());
176+
self.icr().write(|w| w.idlecf().clear_bit_by_one());
179177
}
180178
fn check_and_clear_error_flags(&self) -> Result<(), Error> {
181179
#[cfg(feature = "uart_v2")]
@@ -327,6 +325,7 @@ impl RegisterBlockImpl for crate::pac::usart1::RegisterBlock {
327325
}
328326
}
329327

328+
#[cfg(feature = "f4")]
330329
#[cfg(feature = "uart4")]
331330
impl RegisterBlockImpl for crate::pac::uart4::RegisterBlock {
332331
const IRDA: bool = false;

src/spi.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,8 @@ spi! { pac::SPI1: Spi1, SpiSlave1 }
266266
#[cfg(feature = "spi2")]
267267
#[cfg(not(any(
268268
//feature = "svd-f750",
269-
feature = "svd-f7x6"
269+
feature = "svd-f746",
270+
feature = "svd-f756",
270271
)))]
271272
spi! { pac::SPI2: Spi2, SpiSlave2 }
272273
#[cfg(feature = "spi3")]

0 commit comments

Comments
 (0)