Implement low power functionality on USB subsystem
This enables remote wakeup on CDC driver, so we can safely call standby() and maintain the Serial prints on resume.
This commit is contained in:
parent
95c9ec6fb0
commit
b9ac48c782
4 changed files with 9 additions and 1 deletions
|
|
@ -48,6 +48,7 @@ public:
|
|||
|
||||
inline void runInStandby() { usb.CTRLA.bit.RUNSTDBY = 1; }
|
||||
inline void noRunInStandby() { usb.CTRLA.bit.RUNSTDBY = 0; }
|
||||
inline void wakeupHost() { usb.CTRLB.bit.UPRSM = 1; }
|
||||
|
||||
// USB speed
|
||||
inline void setFullSpeed() { usb.CTRLB.bit.SPDCONF = USB_DEVICE_CTRLB_SPDCONF_FS_Val; }
|
||||
|
|
|
|||
|
|
@ -65,6 +65,8 @@ public:
|
|||
bool configured();
|
||||
bool connected();
|
||||
|
||||
void standby();
|
||||
|
||||
// Setup API
|
||||
bool handleClassInterfaceSetup(USBSetup &setup);
|
||||
bool handleStandardSetup(USBSetup &setup);
|
||||
|
|
|
|||
|
|
@ -250,6 +250,11 @@ bool USBDeviceClass::sendDescriptor(USBSetup &setup)
|
|||
return true;
|
||||
}
|
||||
|
||||
void USBDeviceClass::standby() {
|
||||
usbd.noRunInStandby();
|
||||
}
|
||||
|
||||
|
||||
void USBDeviceClass::handleEndpoint(uint8_t ep)
|
||||
{
|
||||
#if defined(CDC_ENABLED)
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ _Pragma("pack()")
|
|||
* idVendor, idProduct, bcdDevice, iManufacturer, iProduct, iSerialNumber, bNumConfigurations */
|
||||
|
||||
#define D_CONFIG(_totalLength,_interfaces) \
|
||||
{ 9, 2, _totalLength,_interfaces, 1, 0, USB_CONFIG_BUS_POWERED, USB_CONFIG_POWER_MA(500) }
|
||||
{ 9, 2, _totalLength,_interfaces, 1, 0, USB_CONFIG_BUS_POWERED | USB_CONFIG_REMOTE_WAKEUP, USB_CONFIG_POWER_MA(500) }
|
||||
/* Table 9-10. Standard Configuration Descriptor
|
||||
* bLength, bDescriptorType, wTotalLength, bNumInterfaces, bConfigurationValue, iConfiguration
|
||||
* bmAttributes, bMaxPower */
|
||||
|
|
|
|||
Loading…
Reference in a new issue