pub fn poll(&mut self, classes: &mut ClassList<'_, B>) -> bool {
        let pr = self.bus.poll();

        if self.device_state == UsbDeviceState::Suspend {
            match pr {
                PollResult::Suspend | PollResult::None => { return false; },
                _ => {
                    self.bus.resume();
                    self.device_state = UsbDeviceState::Default;
                },
            }
        }

        match pr {
            PollResult::None => { }
            PollResult::Reset => self.reset(classes),
            PollResult::Data { ep_out, ep_in_complete, ep_setup } => {
                // Combine bit fields for quick tests
                let mut eps = ep_out | ep_in_complete | ep_setup;

                // Pending events for endpoint 0?
                if (eps & 1) != 0 {
                    let xfer = if (ep_setup & 1) != 0 {
                        self.control.handle_setup()
                    } else if (ep_out & 1) != 0 {
                        self.control.handle_out()
                    } else {
                        None
                    };

                    match xfer {
                        Some(UsbDirection::In) => self.control_in(classes),
                        Some(UsbDirection::Out) => self.control_out(classes),
                        _ => (),
                    };

                    if (ep_in_complete & 1) != 0 {
                        let completed = self.control.handle_in_complete();

                        if completed && self.pending_address != 0 {
                            self.bus.set_device_address(self.pending_address);
                            self.pending_address = 0;

                            self.device_state = UsbDeviceState::Addressed;
                        }
                    }

                    eps &= !1;
                }

                // Pending events for other endpoints?
                if eps != 0 {
                    let mut bit = 2u16;

                    for i in 1..MAX_ENDPOINTS {
                        if (ep_setup & bit) != 0 {
                            for cls in classes.iter_mut() {
                                cls.endpoint_setup(
                                    EndpointAddress::from_parts(i, UsbDirection::Out));
                            }
                        } else if (ep_out & bit) != 0 {
                            for cls in classes.iter_mut() {
                                cls.endpoint_out(
                                    EndpointAddress::from_parts(i, UsbDirection::Out));
                            }
                        }

                        if (ep_in_complete & bit) != 0 {
                            for cls in classes.iter_mut() {
                                cls.endpoint_in_complete(
                                    EndpointAddress::from_parts(i, UsbDirection::In));
                            }
                        }

                        eps &= !bit;

                        if eps == 0 {
                            // No more pending events for higher endpoints
                            break;
                        }

                        bit <<= 1;
                    }
                }

                for cls in classes.iter_mut() {
                    cls.poll();
                }

                return true;
            },
            PollResult::Resume => { }
            PollResult::Suspend => {
                self.bus.suspend();
                self.device_state = UsbDeviceState::Suspend;
            }
        }

        return false;
    }
/// Polls the [`UsbBus`] for new events and dispatches them to the provided classes. Returns
/// true if one of the classes may have data available for reading or be ready for writing,
/// false otherwise. This should be called periodically as often as possible for the best data
/// rate, or preferably from an interrupt handler. Must be called at least one every 10
/// milliseconds while connected to the USB host to be USB compliant.
///
/// Note: The list of classes passed in must be the same for every call while the device is
/// configured, or the device may enumerate incorrectly or otherwise misbehave. The easiest way
/// to do this is to call the `poll` method in only one place in your code, as follows:
///
/// ``` ignore
/// usb_dev.poll(&mut [&mut class1, &mut class2]);
/// ```
///
/// Strictly speaking the list of classes is allowed to change between polls if the device has
/// been reset, which is indicated by `state` being equal to [`UsbDeviceState::Default`], but
/// this is likely to cause compatibility problems with some operating systems.
Polls the [`UsbBus`] for new events and dispatches them to the provided classes. Returns
true if one of the classes may have data available for reading or be ready for writing,
false otherwise. This should be called periodically as often as possible for the best data
rate, or preferably from an interrupt handler. Must be called at least one every 10
milliseconds while connected to the USB host to be USB compliant.

The list of classes passed in must be the same for every call while the device is
configured, or the device may enumerate incorrectly or otherwise misbehave. The easiest way
to do this is to call the `poll` method in only one place in your code, as follows.



Strictly speaking the list of classes is allowed to change between polls if the device has
been reset, which is indicated by `state` being equal to [`UsbDeviceState::Default`], but
this is likely to cause compatibility problems with some operating systems.
Polls the [ ` UsbBus ` ] for new events and dispatches them to the provided classes . Returns true if one of the classes may have data available for reading or be ready for writing false otherwise . This should be called periodically as often as possible for the best data rate or preferably from an interrupt handler . Must be called at least one every 10 milliseconds while connected to the USB host to be USB compliant . The list of classes passed in must be the same for every call while the device is configured or the device may enumerate incorrectly or otherwise misbehave . The easiest way to do this is to call the ` poll ` method in only one place in your code as follows . Strictly speaking the list of classes is allowed to change between polls if the device has been reset which is indicated by ` state ` being equal to [ ` UsbDeviceState :: Default ` ] but this is likely to cause compatibility problems with some operating systems .
pub fn poll(&mut self, classes: &mut ClassList<'_, B>) -> bool {
        let pr = self.bus.poll();
        if self.device_state == UsbDeviceState::Suspend {
            match pr {
                PollResult::Suspend | PollResult::None => { return false; },
                _ => {
                    self.bus.resume();
                    self.device_state = UsbDeviceState::Default;
                },
            }
        }
        match pr {
            PollResult::None => { }
            PollResult::Reset => self.reset(classes),
            PollResult::Data { ep_out, ep_in_complete, ep_setup } => {
                // Combine bit fields for quick tests
                let mut eps = ep_out | ep_in_complete | ep_setup;
                // Pending events for endpoint 0?
                if (eps & 1) != 0 {
                    let xfer = if (ep_setup & 1) != 0 {
                        self.control.handle_setup()
                    } else if (ep_out & 1) != 0 {
                        self.control.handle_out()
                    } else {
                        None
                    };
                    match xfer {
                        Some(UsbDirection::In) => self.control_in(classes),
                        Some(UsbDirection::Out) => self.control_out(classes),
                        _ => (),
                    };
                    if (ep_in_complete & 1) != 0 {
                        let completed = self.control.handle_in_complete();
                        if completed && self.pending_address != 0 {
                            self.bus.set_device_address(self.pending_address);
                            self.pending_address = 0;
                            self.device_state = UsbDeviceState::Addressed;
                        }
                    }
                    eps &= !1;
                }
                // Pending events for other endpoints?
                if eps != 0 {
                    let mut bit = 2u16;
                    for i in 1..MAX_ENDPOINTS {
                        if (ep_setup & bit) != 0 {
                            for cls in classes.iter_mut() {
                                cls.endpoint_setup(
                                    EndpointAddress::from_parts(i, UsbDirection::Out));
                            }
                        } else if (ep_out & bit) != 0 {
                            for cls in classes.iter_mut() {
                                cls.endpoint_out(
                                    EndpointAddress::from_parts(i, UsbDirection::Out));
                            }
                        }
                        if (ep_in_complete & bit) != 0 {
                            for cls in classes.iter_mut() {
                                cls.endpoint_in_complete(
                                    EndpointAddress::from_parts(i, UsbDirection::In));
                            }
                        }
                        eps &= !bit;
                        if eps == 0 {
                            // No more pending events for higher endpoints
                            break;
                        }
                        bit <<= 1;
                    }
                }
                for cls in classes.iter_mut() {
                    cls.poll();
                }
                return true;
            },
            PollResult::Resume => { }
            PollResult::Suspend => {
                self.bus.suspend();
                self.device_state = UsbDeviceState::Suspend;
            }
        }
        return false;
    }
pub fn poll ( & mut self , classes : & mut ClassList < ' _ , B > ) -> bool { let pr = self . bus . poll ( ) ; if self . device_state == UsbDeviceState :: Suspend { match pr { PollResult :: Suspend | PollResult :: None => { return false ; } , _ => { self . bus . resume ( ) ; self . device_state = UsbDeviceState :: Default ; } , } } match pr { PollResult :: None => { } PollResult :: Reset => self . reset ( classes ) , PollResult :: Data { ep_out , ep_in_complete , ep_setup } => { // Combine bit fields for quick tests let mut eps = ep_out | ep_in_complete | ep_setup ; // Pending events for endpoint 0? if ( eps & 1 ) != 0 { let xfer = if ( ep_setup & 1 ) != 0 { self . control . handle_setup ( ) } else if ( ep_out & 1 ) != 0 { self . control . handle_out ( ) } else { None } ; match xfer { Some ( UsbDirection :: In ) => self . control_in ( classes ) , Some ( UsbDirection :: Out ) => self . control_out ( classes ) , _ => ( ) , } ; if ( ep_in_complete & 1 ) != 0 { let completed = self . control . handle_in_complete ( ) ; if completed && self . pending_address != 0 { self . bus . set_device_address ( self . pending_address ) ; self . pending_address = 0 ; self . device_state = UsbDeviceState :: Addressed ; } } eps &= ! 1 ; } // Pending events for other endpoints? if eps != 0 { let mut bit = 2u16 ; for i in 1 .. MAX_ENDPOINTS { if ( ep_setup & bit ) != 0 { for cls in classes . iter_mut ( ) { cls . endpoint_setup ( EndpointAddress :: from_parts ( i , UsbDirection :: Out ) ) ; } } else if ( ep_out & bit ) != 0 { for cls in classes . iter_mut ( ) { cls . endpoint_out ( EndpointAddress :: from_parts ( i , UsbDirection :: Out ) ) ; } } if ( ep_in_complete & bit ) != 0 { for cls in classes . iter_mut ( ) { cls . endpoint_in_complete ( EndpointAddress :: from_parts ( i , UsbDirection :: In ) ) ; } } eps &= ! bit ; if eps == 0 { // No more pending events for higher endpoints break ; } bit <<= 1 ; } } for cls in classes . iter_mut ( ) { cls . poll ( ) ; } return true ; } , PollResult :: Resume => { } PollResult :: Suspend => { self . bus . suspend ( ) ; self . device_state = UsbDeviceState :: Suspend ; } } return false ; }
Polls the [`UsbBus`] for new events and dispatches them to the provided classes.
Polls the [ ` UsbBus ` ] for new events and dispatches them to the provided classes .
&mut self
classes
&mut ClassList<'_, B>
&mut self
classes
&mut ClassList<'_, B>