Added new NO_DEVICE_SELF_POWER and NO_DEVICE_REMOTE_WAKEUP compile time options.
This commit is contained in:
parent
77cd3a42a7
commit
8b75659563
14 changed files with 146 additions and 86 deletions
|
|
@ -119,6 +119,7 @@
|
|||
*/
|
||||
#define USB_CONFIG_ATTR_BUSPOWERED 0x80
|
||||
|
||||
|
||||
/** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t
|
||||
* descriptor's ConfigAttributes value to indicate that the specified configuration can draw its power
|
||||
* from the device's own power source.
|
||||
|
|
|
|||
|
|
@ -36,8 +36,14 @@
|
|||
#include "DevChapter9.h"
|
||||
|
||||
uint8_t USB_ConfigurationNumber;
|
||||
bool USB_RemoteWakeupEnabled;
|
||||
|
||||
#if !defined(NO_DEVICE_SELF_POWER)
|
||||
bool USB_CurrentlySelfPowered;
|
||||
#endif
|
||||
|
||||
#if !defined(NO_DEVICE_REMOTE_WAKEUP)
|
||||
bool USB_RemoteWakeupEnabled;
|
||||
#endif
|
||||
|
||||
void USB_Device_ProcessControlRequest(void)
|
||||
{
|
||||
|
|
@ -302,12 +308,16 @@ static void USB_Device_GetStatus(void)
|
|||
switch (USB_ControlRequest.bmRequestType)
|
||||
{
|
||||
case (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE):
|
||||
#if !defined(NO_DEVICE_SELF_POWER)
|
||||
if (USB_CurrentlySelfPowered)
|
||||
CurrentStatus |= FEATURE_SELFPOWERED_ENABLED;
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(NO_DEVICE_REMOTE_WAKEUP)
|
||||
if (USB_RemoteWakeupEnabled)
|
||||
CurrentStatus |= FEATURE_REMOTE_WAKEUP_ENABLED;
|
||||
|
||||
#endif
|
||||
|
||||
break;
|
||||
#if !defined(CONTROL_ONLY_DEVICE)
|
||||
case (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_ENDPOINT):
|
||||
|
|
@ -336,10 +346,12 @@ static void USB_Device_ClearSetFeature(void)
|
|||
switch (USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_RECIPIENT)
|
||||
{
|
||||
case REQREC_DEVICE:
|
||||
#if !defined(NO_DEVICE_REMOTE_WAKEUP)
|
||||
if ((uint8_t)USB_ControlRequest.wValue == FEATURE_REMOTE_WAKEUP)
|
||||
USB_RemoteWakeupEnabled = (USB_ControlRequest.bRequest == REQ_SetFeature);
|
||||
else
|
||||
return;
|
||||
#endif
|
||||
|
||||
break;
|
||||
#if !defined(CONTROL_ONLY_DEVICE)
|
||||
|
|
|
|||
|
|
@ -82,23 +82,32 @@
|
|||
*/
|
||||
extern uint8_t USB_ConfigurationNumber;
|
||||
|
||||
/** Indicates if the host is currently allowing the device to issue remote wakeup events. If this
|
||||
* flag is cleared, the device should not issue remote wakeup events to the host.
|
||||
*
|
||||
* \note This variable should be treated as read-only in the user application, and never manually
|
||||
* changed in value.
|
||||
*
|
||||
* \ingroup Group_Device
|
||||
*/
|
||||
extern bool USB_RemoteWakeupEnabled;
|
||||
#if !defined(NO_DEVICE_REMOTE_WAKEUP)
|
||||
/** Indicates if the host is currently allowing the device to issue remote wakeup events. If this
|
||||
* flag is cleared, the device should not issue remote wakeup events to the host.
|
||||
*
|
||||
* \note This variable should be treated as read-only in the user application, and never manually
|
||||
* changed in value.
|
||||
*
|
||||
* \note To reduce FLASH usage of the compiled applications where Remote Wakeup is not supported,
|
||||
* this global and the underlying management code can be disabled by defining the
|
||||
* NO_DEVICE_REMOTE_WAKEUP token in the project makefile and passing it to the compiler via
|
||||
* the -D switch.
|
||||
*
|
||||
* \ingroup Group_Device
|
||||
*/
|
||||
extern bool USB_RemoteWakeupEnabled;
|
||||
#endif
|
||||
|
||||
/** Indicates if the device is currently being powered by its own power supply, rather than being
|
||||
* powered by the host's USB supply. This flag should remain cleared if the device does not
|
||||
* support self powered mode, as indicated in the device descriptors.
|
||||
*
|
||||
* \ingroup Group_Device
|
||||
*/
|
||||
extern bool USB_CurrentlySelfPowered;
|
||||
#if !defined(NO_DEVICE_SELF_POWER)
|
||||
/** Indicates if the device is currently being powered by its own power supply, rather than being
|
||||
* powered by the host's USB supply. This flag should remain cleared if the device does not
|
||||
* support self powered mode, as indicated in the device descriptors.
|
||||
*
|
||||
* \ingroup Group_Device
|
||||
*/
|
||||
extern bool USB_CurrentlySelfPowered;
|
||||
#endif
|
||||
|
||||
/* Private Interface - For use in library only: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
|
|
|
|||
|
|
@ -83,7 +83,8 @@
|
|||
* \note This macro should only be used if the device has indicated to the host that it
|
||||
* supports the Remote Wakeup feature in the device descriptors, and should only be
|
||||
* issued if the host is currently allowing remote wakeup events from the device (i.e.,
|
||||
* the \ref USB_RemoteWakeupEnabled flag is set).
|
||||
* the \ref USB_RemoteWakeupEnabled flag is set). When the NO_DEVICE_REMOTE_WAKEUP compile
|
||||
* time option is used, this macro is unavailable.
|
||||
*
|
||||
* \see \ref Group_Descriptors for more information on the RMWAKEUP feature and device descriptors.
|
||||
*/
|
||||
|
|
@ -96,7 +97,8 @@
|
|||
* a sent RMWAKEUP request was accepted or rejected by the host.
|
||||
*
|
||||
* \note This macro should only be used if the device has indicated to the host that it
|
||||
* supports the Remote Wakeup feature in the device descriptors.
|
||||
* supports the Remote Wakeup feature in the device descriptors. When the NO_DEVICE_REMOTE_WAKEUP
|
||||
* compile time option is used, this macro is unavailable.
|
||||
*
|
||||
* \see \ref Group_Descriptors for more information on the RMWAKEUP feature and device descriptors.
|
||||
*
|
||||
|
|
@ -123,10 +125,12 @@
|
|||
*/
|
||||
static inline bool USB_Device_DisableSOFEvents(void);
|
||||
#else
|
||||
#define USB_Device_SendRemoteWakeup() MACROS{ UDCON |= (1 << RMWKUP); }MACROE
|
||||
|
||||
#define USB_Device_IsRemoteWakeupSent() ((UDCON & (1 << RMWKUP)) ? false : true)
|
||||
#if !defined(NO_DEVICE_REMOTE_WAKEUP)
|
||||
#define USB_Device_SendRemoteWakeup() MACROS{ UDCON |= (1 << RMWKUP); }MACROE
|
||||
|
||||
#define USB_Device_IsRemoteWakeupSent() ((UDCON & (1 << RMWKUP)) ? false : true)
|
||||
#endif
|
||||
|
||||
#define USB_Device_IsUSBSuspended() ((UDINT & (1 << SUSPI)) ? true : false)
|
||||
|
||||
#define USB_Device_EnableSOFEvents() MACROS{ USB_INT_Enable(USB_INT_SOFI); }MACROE
|
||||
|
|
|
|||
|
|
@ -142,8 +142,14 @@ void USB_ResetInterface(void)
|
|||
#if defined(USB_CAN_BE_DEVICE)
|
||||
USB_DeviceState = DEVICE_STATE_Unattached;
|
||||
USB_ConfigurationNumber = 0;
|
||||
USB_RemoteWakeupEnabled = false;
|
||||
USB_CurrentlySelfPowered = false;
|
||||
|
||||
#if !defined(NO_DEVICE_REMOTE_WAKEUP)
|
||||
USB_RemoteWakeupEnabled = false;
|
||||
#endif
|
||||
|
||||
#if !defined(NO_DEVICE_SELF_POWER)
|
||||
USB_CurrentlySelfPowered = false;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (!(USB_Options & USB_OPT_MANUAL_PLL))
|
||||
|
|
|
|||
|
|
@ -21,13 +21,16 @@ uint8_t TEMPLATE_FUNC_NAME (const void* Buffer, uint16_t Length)
|
|||
|
||||
if (Endpoint_IsINReady())
|
||||
{
|
||||
while (Length && (Endpoint_BytesInEndpoint() < USB_ControlEndpointSize))
|
||||
uint16_t BytesInEndpoint = Endpoint_BytesInEndpoint();
|
||||
|
||||
while (Length && (BytesInEndpoint < USB_ControlEndpointSize))
|
||||
{
|
||||
TEMPLATE_TRANSFER_BYTE(DataStream);
|
||||
Length--;
|
||||
BytesInEndpoint++;
|
||||
}
|
||||
|
||||
LastPacketFull = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize);
|
||||
LastPacketFull = (BytesInEndpoint == USB_ControlEndpointSize);
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue