feat(UsbBus): implement resume and set_device_address methods
This commit is contained in:
parent
ecb5e513d1
commit
64424febc6
|
@ -275,11 +275,45 @@ impl<const L: usize> UsbBus for UsbDevice<L> {
|
|||
}
|
||||
|
||||
fn resume(&self) {
|
||||
todo!();
|
||||
free(|cs| {
|
||||
let usb = self.usb.borrow(cs);
|
||||
let pll = self.pll.borrow(cs);
|
||||
|
||||
// Enable PLL and wait PLL lock. //
|
||||
|
||||
pll.pllcsr.modify(|_, w| w.plle().set_bit());
|
||||
|
||||
while pll.pllcsr.read().plock().bit_is_clear() {}
|
||||
|
||||
// Unfreeze USB clock. //
|
||||
|
||||
usb.usbcon.modify(|_, w| w.frzclk().clear_bit());
|
||||
|
||||
// Clear resume informations. //
|
||||
|
||||
usb.udint
|
||||
.modify(|_, w| w.wakeupi().clear_bit().suspi().clear_bit());
|
||||
|
||||
usb.udien
|
||||
.modify(|_, w| w.wakeupe().clear_bit().suspe().set_bit());
|
||||
})
|
||||
}
|
||||
|
||||
fn set_device_address(&self, addr: u8) {
|
||||
todo!();
|
||||
free(|cs| {
|
||||
let usb = self.usb.borrow(cs);
|
||||
|
||||
// Set address. //
|
||||
|
||||
usb.udaddr.modify(|_, w| w.uadd().bits(addr));
|
||||
|
||||
// Note: ADDEN and UADD shall not be written at the same time.
|
||||
// (written in atmega32u4/16u4 docs)
|
||||
|
||||
// Enable. //
|
||||
|
||||
usb.udaddr.modify(|_, w| w.adden().set_bit());
|
||||
});
|
||||
}
|
||||
|
||||
fn set_stalled(&self, ep_addr: usb_device::endpoint::EndpointAddress, stalled: bool) {
|
||||
|
|
Loading…
Reference in New Issue