Skip to content

Commit 7c5693a

Browse files
committed
Update stm32-usbd to v0.6.0
1 parent 759fbb7 commit 7c5693a

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

Cargo.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ edition = "2018"
1212
version = "0.7.0"
1313

1414
[package.metadata.docs.rs]
15-
features = ["stm32f103", "rt", "stm32-usbd"]
15+
features = ["stm32f103", "rt"]
1616
default-target = "x86_64-unknown-linux-gnu"
1717

1818
[dependencies]
@@ -36,8 +36,7 @@ version = "0.2.3"
3636
features = ["unproven"]
3737

3838
[dependencies.stm32-usbd]
39-
version = "0.5.0"
40-
features = ["ram_access_1x16"]
39+
version = "0.6.0"
4140
optional = true
4241

4342
[dev-dependencies]
@@ -79,7 +78,7 @@ doc = []
7978
rt = ["stm32f1/rt"]
8079
stm32f100 = ["stm32f1/stm32f100", "device-selected"]
8180
stm32f101 = ["stm32f1/stm32f101", "device-selected"]
82-
stm32f103 = ["stm32f1/stm32f103", "device-selected", "has-can"]
81+
stm32f103 = ["stm32f1/stm32f103", "device-selected", "has-can", "stm32-usbd"]
8382
stm32f105 = ["stm32f1/stm32f107", "device-selected", "connectivity"]
8483
stm32f107 = ["stm32f1/stm32f107", "device-selected", "connectivity"]
8584

src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,7 @@ pub mod spi;
180180
pub mod time;
181181
#[cfg(feature = "device-selected")]
182182
pub mod timer;
183-
#[cfg(all(
184-
feature = "stm32-usbd",
185-
any(feature = "stm32f102", feature = "stm32f103")
186-
))]
183+
#[cfg(all(feature = "device-selected", feature = "stm32-usbd"))]
187184
pub mod usb;
188185
#[cfg(feature = "device-selected")]
189186
pub mod watchdog;

src/usb.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
//! for usage examples.
66
77
use crate::pac::{RCC, USB};
8+
use crate::rcc::{Enable, Reset};
89
use stm32_usbd::UsbPeripheral;
910

1011
use crate::gpio::gpioa::{PA11, PA12};
@@ -24,18 +25,17 @@ unsafe impl UsbPeripheral for Peripheral {
2425
const DP_PULL_UP_FEATURE: bool = false;
2526
const EP_MEMORY: *const () = 0x4000_6000 as _;
2627
const EP_MEMORY_SIZE: usize = 512;
28+
const EP_MEMORY_ACCESS_2X16: bool = false;
2729

2830
fn enable() {
29-
let rcc = unsafe { (&*RCC::ptr()) };
31+
unsafe {
32+
let rcc = &*RCC::ptr();
3033

31-
cortex_m::interrupt::free(|_| {
3234
// Enable USB peripheral
33-
rcc.apb1enr.modify(|_, w| w.usben().set_bit());
34-
35+
USB::enable(rcc);
3536
// Reset USB peripheral
36-
rcc.apb1rstr.modify(|_, w| w.usbrst().set_bit());
37-
rcc.apb1rstr.modify(|_, w| w.usbrst().clear_bit());
38-
});
37+
USB::reset(rcc);
38+
}
3939
}
4040

4141
fn startup_delay() {

0 commit comments

Comments
 (0)