+
+static mut USB_ALLOCATOR: Option<UsbBusAllocator<UsbBus>> = None;
+static mut USB_BUS: Option<UsbDevice<UsbBus>> = None;
+static mut USB_SERIAL: Option<SerialPort<UsbBus>> = None;
+
+fn poll_usb() {
+ unsafe {
+ USB_BUS.as_mut().map(|usb_dev| {
+ USB_SERIAL.as_mut().map(|serial| {
+ usb_dev.poll(&mut [serial]);
+ let mut buf = [0u8; 64];
+
+ if let Ok(count) = serial.read(&mut buf) {
+ for (i, c) in buf.iter().enumerate() {
+ if i >= count {
+ break;
+ }
+ serial.write(&[c.clone()]);
+ }
+ };
+ });
+ });
+ };
+}
+
+#[interrupt]
+fn USB() {
+ poll_usb();
+}
\ No newline at end of file