usb: Add remote wakeup support

This commit adds support for remote wakeup and extends USB api
with a wakeup request call. Remote wakeup can be dsabled in kconfig
when a specific driver does not support this feature.

Signed-off-by: Paweł Zadrożniak <pawel.zadrozniak@nordicsemi.no>
This commit is contained in:
Paweł Zadrożniak 2019-02-07 13:19:16 +01:00 committed by Anas Nashif
commit 3ecbff501a
6 changed files with 68 additions and 5 deletions

View file

@ -96,7 +96,10 @@
* D5:Remote Wakeup -> 0,
* D4...0:Reserved -> 0
*/
#define USB_CONFIGURATION_ATTRIBUTES 0xC0
#define USB_CONFIGURATION_ATTRIBUTES_REMOTE_WAKEUP 0x20
#define USB_CONFIGURATION_ATTRIBUTES 0xC0 \
| (COND_CODE_1(CONFIG_USB_DEVICE_REMOTE_WAKEUP, \
(USB_CONFIGURATION_ATTRIBUTES_REMOTE_WAKEUP), (0)))
/* Classes */
#define COMMUNICATION_DEVICE_CLASS 0x02

View file

@ -418,6 +418,18 @@ int usb_transfer_sync(u8_t ep, u8_t *data, size_t dlen, unsigned int flags);
*/
void usb_cancel_transfer(u8_t ep);
/**
* @brief Start the USB remote wakeup procedure
*
* Function to request a remote wakeup.
* This feature must be enabled in configuration, otherwise
* it will always return -ENOTSUP error.
*
* @return 0 on success, negative errno code on fail,
* i.e. when the bus is already active.
*/
int usb_wakeup_request(void);
/**
* @}
*/

View file

@ -71,6 +71,9 @@
#define FEA_REMOTE_WAKEUP 0x01
#define FEA_TEST_MODE 0x02
#define DEVICE_STATUS_SELF_POWERED 0x01
#define DEVICE_STATUS_REMOTE_WAKEUP 0x02
/*
* USB descriptors
*/