aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers/USB/LowLevel
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-12-20 13:00:49 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-12-20 13:00:49 +0000
commit8b7565956380c558bb309732c1d7d2cb58b193ea (patch)
treedaa5f27642bd8672bbb426fefccf92eb2c974c74 /LUFA/Drivers/USB/LowLevel
parent77cd3a42a7eda45138fc9a0fc6a9badd68caac96 (diff)
downloadlufa-8b7565956380c558bb309732c1d7d2cb58b193ea.tar.gz
lufa-8b7565956380c558bb309732c1d7d2cb58b193ea.tar.bz2
lufa-8b7565956380c558bb309732c1d7d2cb58b193ea.zip
Added new NO_DEVICE_SELF_POWER and NO_DEVICE_REMOTE_WAKEUP compile time options.
Diffstat (limited to 'LUFA/Drivers/USB/LowLevel')
-rw-r--r--LUFA/Drivers/USB/LowLevel/DevChapter9.c18
-rw-r--r--LUFA/Drivers/USB/LowLevel/DevChapter9.h41
-rw-r--r--LUFA/Drivers/USB/LowLevel/Device.h14
-rw-r--r--LUFA/Drivers/USB/LowLevel/LowLevel.c10
-rw-r--r--LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_W.c7
5 files changed, 62 insertions, 28 deletions
diff --git a/LUFA/Drivers/USB/LowLevel/DevChapter9.c b/LUFA/Drivers/USB/LowLevel/DevChapter9.c
index 6e7b2c718..3f0976b5c 100644
--- a/LUFA/Drivers/USB/LowLevel/DevChapter9.c
+++ b/LUFA/Drivers/USB/LowLevel/DevChapter9.c
@@ -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)
diff --git a/LUFA/Drivers/USB/LowLevel/DevChapter9.h b/LUFA/Drivers/USB/LowLevel/DevChapter9.h
index e6baca2be..8b6498275 100644
--- a/LUFA/Drivers/USB/LowLevel/DevChapter9.h
+++ b/LUFA/Drivers/USB/LowLevel/DevChapter9.h
@@ -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__)
diff --git a/LUFA/Drivers/USB/LowLevel/Device.h b/LUFA/Drivers/USB/LowLevel/Device.h
index acffd806b..74736a776 100644
--- a/LUFA/Drivers/USB/LowLevel/Device.h
+++ b/LUFA/Drivers/USB/LowLevel/Device.h
@@ -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
diff --git a/LUFA/Drivers/USB/LowLevel/LowLevel.c b/LUFA/Drivers/USB/LowLevel/LowLevel.c
index 5ac476125..eb8ee1eef 100644
--- a/LUFA/Drivers/USB/LowLevel/LowLevel.c
+++ b/LUFA/Drivers/USB/LowLevel/LowLevel.c
@@ -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))
diff --git a/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_W.c b/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_W.c
index 2de7a74f5..70560cf46 100644
--- a/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_W.c
+++ b/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_W.c
@@ -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();
}
}