Function teensy4_bsp::usb::poll[][src]

pub unsafe fn poll() -> PollStatus
This is supported on crate feature usb-logging only.
Expand description

Drive the USB device event loop

poll must be called fast enough to handled the speed of your USB host. It will typically run as a USB high speed device. Consider calling poll in the USB_OTG1 ISR, or in your idle loop. If calling poll in a USB ISR, make sure you unmask the interrupt.

For a safer polling interface, see Poller.

Safety

poll modifies USB driver state, and this may happen without synchronization. Users are responsible for serializing calls to poll.

Example

How to set up the USB ISR using the unsafe poll function.

use teensy4_bsp as bsp;
use bsp::interrupt;

// #[cortex_m_rt::interrupt]
unsafe fn USB_OTG1() { bsp::usb::poll(); }

// Unmask you interrupt once the USB system is enabled,
// and your ISR state is ready.
unsafe { cortex_m::peripheral::NVIC::unmask(interrupt::USB_OTG1) };