Skip to content

Commit 4ba4540

Browse files
committed
please stop yelling at me :(
1 parent 56c4c6d commit 4ba4540

1 file changed

Lines changed: 10 additions & 12 deletions

File tree

src/main.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -150,18 +150,16 @@ fn main() -> ! {
150150
});
151151

152152
// Create the USB Bus Allocator
153-
let usb_bus = UsbBusAllocator::new(hal::usb::UsbBus::new(
154-
pac.USBCTRL_REGS,
155-
pac.USBCTRL_DPRAM,
156-
clocks.usb_clock,
157-
true,
158-
&mut pac.RESETS,
159-
));
160-
let bus_ref = unsafe {
161-
static mut USB_BUS: Option<UsbBusAllocator<hal::usb::UsbBus>> = None;
162-
USB_BUS = Some(usb_bus);
163-
USB_BUS.as_ref().unwrap()
164-
};
153+
static USB_BUS: StaticCell<UsbBusAllocator<hal::usb::UsbBus>> = StaticCell::new();
154+
let bus_ref = USB_BUS.init_with(|| {
155+
UsbBusAllocator::new(hal::usb::UsbBus::new(
156+
pac.USBCTRL_REGS,
157+
pac.USBCTRL_DPRAM,
158+
clocks.usb_clock,
159+
true,
160+
&mut pac.RESETS,
161+
))
162+
});
165163

166164
// Set up the USB HID Class Device driver, providing Mouse Reports
167165
let player_one = create_hid_class(bus_ref);

0 commit comments

Comments
 (0)