Remote wake lets a local action ask a suspended computer to resume. Leave it off unless your project needs it. When you use it, both the device and the host must allow it, and your program must provide the timing described below.
USB_Tick(nowMs) takes your running millisecond counter as a Word. Pass its current total, not a constant 1 and not the time since the previous call. It supports the normal wrap from 65535 to 0 and leaves USB_Result unchanged. You do not need this extra clock for ordinary transfers when remote wake is off.
Call from foreground at least once per millisecond while using remote wake, including during suspend and signaling. A timer ISR can maintain the application's count; copy it consistently before passing it. USB_Frame is unsuitable because USB frames stop during suspend.
USB_RemoteWake() requests host resume after a local event. Enable the feature in the tool; the host must also authorize it. The device must be configured, suspended, and already have valid tick timing when suspend is observed. After at least 5 ms of suspend, an accepted request returns USB_OK. USB_BUSY means the wait has not elapsed or signaling is already active. USB_NOT_SUPPORTED also covers missing prerequisites.
Keep ticking afterward: the library ends its nominal 10 ms resume signal only when a later tick observes elapsed time. Do not block or stop that clock; signaling must not exceed the USB limit of 15 ms. Restore any oscillator settings changed for application power saving before requesting wake. Check actual timing on your board. Suspend does not automatically put the CPU to sleep, and acceptance does not guarantee the PC's policy will wake its user session. Browser mode does not offer this feature.
Created with the Personal Edition of HelpNDoc: Full-featured EBook editor