Skip to content

Commit 759fbb7

Browse files
committed
Fix USB examples
1 parent adc4e8c commit 759fbb7

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

examples/usb_serial.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extern crate panic_semihosting;
1414
use cortex_m::asm::delay;
1515
use cortex_m_rt::entry;
1616
use stm32f1xx_hal::usb::{Peripheral, UsbBus};
17-
use stm32f1xx_hal::{prelude::*, stm32};
17+
use stm32f1xx_hal::{pac, prelude::*};
1818
use usb_device::prelude::*;
1919
use usbd_serial::{SerialPort, USB_CLASS_CDC};
2020

@@ -23,7 +23,7 @@ fn main() -> ! {
2323
let dp = pac::Peripherals::take().unwrap();
2424

2525
let mut flash = dp.FLASH.constrain();
26-
let mut rcc = dp.RCC.constrain();
26+
let rcc = dp.RCC.constrain();
2727

2828
let clocks = rcc
2929
.cfgr

examples/usb_serial_interrupt.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ extern crate panic_semihosting;
77

88
use cortex_m::asm::{delay, wfi};
99
use cortex_m_rt::entry;
10-
use stm32f1xx_hal::pac::{interrupt, Interrupt};
10+
use stm32f1xx_hal::pac::{self, interrupt, Interrupt, NVIC};
11+
use stm32f1xx_hal::prelude::*;
1112
use stm32f1xx_hal::usb::{Peripheral, UsbBus, UsbBusType};
12-
use stm32f1xx_hal::{prelude::*, stm32};
1313
use usb_device::{bus::UsbBusAllocator, prelude::*};
1414
use usbd_serial::{SerialPort, USB_CLASS_CDC};
1515

@@ -19,11 +19,10 @@ static mut USB_DEVICE: Option<UsbDevice<UsbBusType>> = None;
1919

2020
#[entry]
2121
fn main() -> ! {
22-
let p = cortex_m::Peripherals::take().unwrap();
2322
let dp = pac::Peripherals::take().unwrap();
2423

2524
let mut flash = dp.FLASH.constrain();
26-
let mut rcc = dp.RCC.constrain();
25+
let rcc = dp.RCC.constrain();
2726

2827
let clocks = rcc
2928
.cfgr
@@ -71,10 +70,10 @@ fn main() -> ! {
7170
USB_DEVICE = Some(usb_dev);
7271
}
7372

74-
let mut nvic = p.NVIC;
75-
76-
nvic.enable(Interrupt::USB_HP_CAN_TX);
77-
nvic.enable(Interrupt::USB_LP_CAN_RX0);
73+
unsafe {
74+
NVIC::unmask(Interrupt::USB_HP_CAN_TX);
75+
NVIC::unmask(Interrupt::USB_LP_CAN_RX0);
76+
}
7877

7978
loop {
8079
wfi();

examples/usb_serial_rtic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const APP: () = {
2626
static mut USB_BUS: Option<bus::UsbBusAllocator<UsbBusType>> = None;
2727

2828
let mut flash = cx.device.FLASH.constrain();
29-
let mut rcc = cx.device.RCC.constrain();
29+
let rcc = cx.device.RCC.constrain();
3030

3131
let clocks = rcc
3232
.cfgr

0 commit comments

Comments
 (0)