- let pins = bsp::Pins::new(peripherals.PORT);
- let mut red_led: bsp::RedLed = pins.d13.into();
- let mut delay = Delay::new(core.SYST, &mut clocks);
+ let mut pins = hal::Pins::new(peripherals.PORT);
+ let mut red_led = pins.d13.into_open_drain_output(&mut pins.port);
+
+ let bus_allocator = unsafe {
+ USB_ALLOCATOR = Some(hal::usb_allocator(
+ peripherals.USB,
+ &mut clocks,
+ &mut peripherals.PM,
+ pins.usb_dm,
+ pins.usb_dp,
+ &mut pins.port,
+ ));
+ USB_ALLOCATOR.as_ref().unwrap()
+ };
+
+ unsafe {
+ USB_SERIAL = Some(SerialPort::new(&bus_allocator));
+ USB_BUS = Some(
+ UsbDeviceBuilder::new(&bus_allocator, UsbVidPid(0x16c0, 0x27dd))
+ .manufacturer("Fake company")
+ .product("Serial port")
+ .serial_number("TEST")
+ .device_class(USB_CLASS_CDC)
+ .build(),
+ );
+ }
+
+ unsafe {
+ core.NVIC.set_priority(interrupt::USB, 1);
+ NVIC::unmask(interrupt::USB);
+ }
+
+ // Flash the LED in a spin loop to demonstrate that USB is
+ // entirely interrupt driven.