-
-
Save spookyvision/02e02f30ff12f982f2463a58c9be1787 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static mut USB_SERIAL: Option<usbd_serial::SerialPort<UsbBusType>> = None; | |
static mut USB_DEVICE: Option<UsbDevice<UsbBusType>> = None; | |
#[entry] | |
fn main() -> ! { | |
if let (Some(dp), Some(mut cp)) = (pac::Peripherals::take(), Peripherals::take()) { | |
// ... | |
unsafe { | |
let bus = UsbBus::new(usb); | |
USB_BUS = Some(bus); | |
USB_SERIAL = Some(SerialPort::new(USB_BUS.as_ref().unwrap())); | |
USB_DEVICE = Some( /* ... */ ); | |
// ... | |
} | |
} | |
#[interrupt] | |
fn USB_HP_CAN_TX() { | |
usb_interrupt(); | |
} | |
#[interrupt] | |
fn USB_LP_CAN_RX0() { | |
usb_interrupt(); | |
} | |
fn usb_interrupt() { | |
let usb_dev = unsafe { USB_DEVICE.as_mut().unwrap() }; | |
cortex_m::interrupt::free(|_| unsafe { | |
// ... use it |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment