fn _attach(&self) {
        self.state.map(|state| {
            match *state {
                State::Reset => {
                    client_err!("Not enabled");
                }
                State::Active(_) => {
                    client_err!("Already attached");
                }
                State::Idle(mode) => {
                    if pm::get_system_frequency() == 48000000 {
                        // XX: not clear that this always results in a usable USB clock
                        scif::generic_clock_enable(
                            scif::GenericClock::GCLK7,
                            scif::ClockSource::CLK_HSB,
                        );

                        while !USBSTA_CLKUSABLE.read() {}

                        UDCON_DETACH.write(false);
                        debug!("Attached.");

                        *state = State::Active(mode);
                    } else {
                        debug!("The system clock does not support USB");
                    }
                }
            }
        });
    }
/// Attach to the USB bus after enabling USB clock
Attach to the USB bus after enabling USB clock
Attach to the USB bus after enabling USB clock
fn _attach(&self) {
        self.state.map(|state| {
            match *state {
                State::Reset => {
                    client_err!("Not enabled");
                }
                State::Active(_) => {
                    client_err!("Already attached");
                }
                State::Idle(mode) => {
                    if pm::get_system_frequency() == 48000000 {
                        // XX: not clear that this always results in a usable USB clock
                        scif::generic_clock_enable(
                            scif::GenericClock::GCLK7,
                            scif::ClockSource::CLK_HSB,
                        );
                        while !USBSTA_CLKUSABLE.read() {}
                        UDCON_DETACH.write(false);
                        debug!("Attached.");
                        *state = State::Active(mode);
                    } else {
                        debug!("The system clock does not support USB");
                    }
                }
            }
        });
    }
fn _attach ( & self ) { self . state . map ( | state | { match * state { State :: Reset => { client_err ! ( " " ) ; } State :: Active ( _ ) => { client_err ! ( " " ) ; } State :: Idle ( mode ) => { if pm :: get_system_frequency ( ) == 48000000 { // XX: not clear that this always results in a usable USB clock scif :: generic_clock_enable ( scif :: GenericClock :: GCLK7 , scif :: ClockSource :: CLK_HSB , ) ; while ! USBSTA_CLKUSABLE . read ( ) { } UDCON_DETACH . write ( false ) ; debug ! ( " " ) ; * state = State :: Active ( mode ) ; } else { debug ! ( " " ) ; } } } } ) ; }
Attach to the USB bus after enabling USB clock
Attach to the USB bus after enabling USB clock
&self
&self