File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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) ;
You can’t perform that action at this time.
0 commit comments