Skip to content

Commit c6f7d12

Browse files
committed
Add method for implementing remote wakeup method
1 parent 3507c24 commit c6f7d12

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/bus.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,23 @@ impl<USB: UsbPeripheral> UsbBus<USB> {
9292
}
9393
})
9494
}
95+
96+
/// Set/clear remote wakeup bit
97+
///
98+
/// Allows to modify CNTR.RESUME bit from device to perform remote wake up from suspend
99+
/// (e.g. on keyboard/mouse input). To perform remote wake up: when a condition is met
100+
/// during suspend mode, use this method with `true` to set the RESUME bit. Then, after
101+
/// waiting between 1-15 ms (see reference manual) call it again with `false` to clear
102+
/// the bit.
103+
///
104+
/// This method will not set the bit if device is not suspended because performing remote
105+
/// wake up in other mode is invalid and host will most likely disable such a device.
106+
pub fn remote_wakeup(&self, resume: bool) {
107+
interrupt::free(|cs| {
108+
self.regs.borrow(cs)
109+
.cntr.modify(|r, w| w.resume().bit(resume && r.fsusp().is_suspend()));
110+
})
111+
}
95112
}
96113

97114
impl<USB: UsbPeripheral> usb_device::bus::UsbBus for UsbBus<USB> {

0 commit comments

Comments
 (0)