diff options
Diffstat (limited to 'LUFA')
-rw-r--r-- | LUFA/ChangeLog.txt | 2 | ||||
-rw-r--r-- | LUFA/CompileTimeTokens.txt | 8 | ||||
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/DevChapter9.c | 49 | ||||
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/DevChapter9.h | 2 | ||||
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/Endpoint.c | 2 | ||||
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/Endpoint.h | 56 | ||||
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/LowLevel.c | 13 | ||||
-rw-r--r-- | LUFA/MigrationInformation.txt | 1 |
8 files changed, 88 insertions, 45 deletions
diff --git a/LUFA/ChangeLog.txt b/LUFA/ChangeLog.txt index 3825cd343..1557db500 100644 --- a/LUFA/ChangeLog.txt +++ b/LUFA/ChangeLog.txt @@ -59,6 +59,8 @@ * rather than having the library pass only partially read header data to the application
* - The USB_UnhandledControlPacket event has had its parameters removed, in favour of accessing the new USB_ControlRequest structure
* - The Endpoint control stream functions now correctly send a ZLP to the host when less data than requested is sent
+ * - Fixed USB_RemoteWakeupEnabled flag never being set (the REMOTE WAKEUP Set Feature request was not being handled)
+ * - Renamed the FEATURELESS_CONTROL_ONLY_DEVICE compile-time token to CONTROL_ONLY_DEVICE
*
*
* \section Sec_ChangeLog090401 Version 090401
diff --git a/LUFA/CompileTimeTokens.txt b/LUFA/CompileTimeTokens.txt index 0dc4be08b..090ace8ce 100644 --- a/LUFA/CompileTimeTokens.txt +++ b/LUFA/CompileTimeTokens.txt @@ -114,10 +114,10 @@ * EEPROM or RAM rather than flash memory) and reduces code maintenance. However, many USB device projects use only a single configuration.
* Defining this token enables single-configuration mode, reducing the compiled size of the binary at the expense of flexibility.
*
- * <b>FEATURELESS_CONTROL_ONLY_DEVICE</b> \n
- * In some limited USB device applications, device features (other than self-power) and endpoints other than the control endpoint aren't
- * used. In such limited situations, this token may be defined to remove the handling of the Set Feature Chapter 9 request entirely and
- * parts of the Get Feature chapter 9 request to save space. Generally, this is usually only useful in (some) bootloaders and is best avoided.
+ * <b>CONTROL_ONLY_DEVICE</b> \n
+ * In some limited USB device applications, there are no device endpoints other than the control endpoint; i.e. all device communication
+ * is through control endpoint requests. Defining this token will remove several features related to the selection and control of device
+ * endpoints internally, saving space. Generally, this is usually only useful in (some) bootloaders and is best avoided.
*
* <b>NO_STREAM_CALLBACKS</b> - ( \ref Group_EndpointPacketManagement , \ref Group_PipePacketManagement )\n
* Both the endpoint and the pipe driver code contains stream functions, allowing for arrays of data to be sent to or from the
diff --git a/LUFA/Drivers/USB/LowLevel/DevChapter9.c b/LUFA/Drivers/USB/LowLevel/DevChapter9.c index bf2b12761..bf1cb6c8f 100644 --- a/LUFA/Drivers/USB/LowLevel/DevChapter9.c +++ b/LUFA/Drivers/USB/LowLevel/DevChapter9.c @@ -46,31 +46,31 @@ void USB_Device_ProcessControlPacket(void) for (uint8_t RequestHeaderByte = 0; RequestHeaderByte < sizeof(USB_Request_Header_t); RequestHeaderByte++)
*(RequestHeader++) = Endpoint_Read_Byte();
+
+ uint8_t bmRequestType = USB_ControlRequest.bmRequestType;
switch (USB_ControlRequest.bRequest)
{
case REQ_GetStatus:
- if ((USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE)) ||
- (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_ENDPOINT)))
+ if ((bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE)) ||
+ (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_ENDPOINT)))
{
USB_Device_GetStatus();
RequestHandled = true;
}
break;
-#if !defined(FEATURELESS_CONTROL_ONLY_DEVICE)
case REQ_ClearFeature:
case REQ_SetFeature:
- if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_ENDPOINT))
+ if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_ENDPOINT))
{
USB_Device_ClearSetFeature();
RequestHandled = true;
}
break;
-#endif
case REQ_SetAddress:
- if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE))
+ if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE))
{
USB_Device_SetAddress();
RequestHandled = true;
@@ -78,8 +78,8 @@ void USB_Device_ProcessControlPacket(void) break;
case REQ_GetDescriptor:
- if ((USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE)) ||
- (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_INTERFACE)))
+ if ((bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE)) ||
+ (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_INTERFACE)))
{
USB_Device_GetDescriptor();
RequestHandled = true;
@@ -87,7 +87,7 @@ void USB_Device_ProcessControlPacket(void) break;
case REQ_GetConfiguration:
- if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE))
+ if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE))
{
USB_Device_GetConfiguration();
RequestHandled = true;
@@ -95,7 +95,7 @@ void USB_Device_ProcessControlPacket(void) break;
case REQ_SetConfiguration:
- if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE))
+ if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE))
{
USB_Device_SetConfiguration();
RequestHandled = true;
@@ -124,7 +124,7 @@ static void USB_Device_SetAddress(void) while (!(Endpoint_IsINReady()));
- UDADDR = ((1 << ADDEN) | (USB_ControlRequest.wValue & 0x7F));
+ UDADDR = ((1 << ADDEN) | ((uint8_t)USB_ControlRequest.wValue & 0x7F));
return;
}
@@ -134,17 +134,17 @@ static void USB_Device_SetConfiguration(void) bool AlreadyConfigured = (USB_ConfigurationNumber != 0);
#if defined(USE_SINGLE_DEVICE_CONFIGURATION)
- if (USB_ControlRequest.wValue > 1)
+ if ((uint8_t)USB_ControlRequest.wValue > 1)
#else
USB_Descriptor_Device_t* DevDescriptorPtr;
if ((USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DevDescriptorPtr) == NO_DESCRIPTOR) ||
#if defined(USE_RAM_DESCRIPTORS)
- (USB_ControlRequest.wValue > DevDescriptorPtr->NumberOfConfigurations))
+ ((uint8_t)USB_ControlRequest.wValue > DevDescriptorPtr->NumberOfConfigurations))
#elif defined (USE_EEPROM_DESCRIPTORS)
- (USB_ControlRequest.wValue > eeprom_read_byte(&DevDescriptorPtr->NumberOfConfigurations)))
+ ((uint8_t)USB_ControlRequest.wValue > eeprom_read_byte(&DevDescriptorPtr->NumberOfConfigurations)))
#else
- (USB_ControlRequest.wValue > pgm_read_byte(&DevDescriptorPtr->NumberOfConfigurations)))
+ ((uint8_t)USB_ControlRequest.wValue > pgm_read_byte(&DevDescriptorPtr->NumberOfConfigurations)))
#endif
#endif
{
@@ -153,7 +153,7 @@ static void USB_Device_SetConfiguration(void) Endpoint_ClearSETUP();
- USB_ConfigurationNumber = USB_ControlRequest.wValue;
+ USB_ConfigurationNumber = (uint8_t)USB_ControlRequest.wValue;
Endpoint_ClearIN();
@@ -245,9 +245,9 @@ static void USB_Device_GetStatus(void) CurrentStatus |= FEATURE_REMOTE_WAKEUP_ENABLED;
break;
-#if !defined(FEATURELESS_CONTROL_ONLY_DEVICE)
+#if !defined(CONTROL_ONLY_DEVICE)
case (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_ENDPOINT):
- Endpoint_SelectEndpoint(USB_ControlRequest.wIndex);
+ Endpoint_SelectEndpoint((uint8_t)USB_ControlRequest.wIndex);
CurrentStatus = Endpoint_IsStalled();
@@ -267,15 +267,20 @@ static void USB_Device_GetStatus(void) Endpoint_ClearOUT();
}
-#if !defined(FEATURELESS_CONTROL_ONLY_DEVICE)
static void USB_Device_ClearSetFeature(void)
{
switch (USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_RECIPIENT)
{
+ case REQREC_DEVICE:
+ if ((uint8_t)USB_ControlRequest.wValue == FEATURE_REMOTE_WAKEUP)
+ USB_RemoteWakeupEnabled = (USB_ControlRequest.bRequest == REQ_SetFeature);
+
+ break;
+#if !defined(CONTROL_ONLY_DEVICE)
case REQREC_ENDPOINT:
- if (USB_ControlRequest.wValue == FEATURE_ENDPOINT_HALT)
+ if ((uint8_t)USB_ControlRequest.wValue == FEATURE_ENDPOINT_HALT)
{
- uint8_t EndpointIndex = (USB_ControlRequest.wIndex & ENDPOINT_EPNUM_MASK);
+ uint8_t EndpointIndex = ((uint8_t)USB_ControlRequest.wIndex & ENDPOINT_EPNUM_MASK);
if (EndpointIndex != ENDPOINT_CONTROLEP)
{
@@ -302,8 +307,8 @@ static void USB_Device_ClearSetFeature(void) }
break;
+#endif
}
}
-#endif
#endif
diff --git a/LUFA/Drivers/USB/LowLevel/DevChapter9.h b/LUFA/Drivers/USB/LowLevel/DevChapter9.h index b3cac2d50..3369b5192 100644 --- a/LUFA/Drivers/USB/LowLevel/DevChapter9.h +++ b/LUFA/Drivers/USB/LowLevel/DevChapter9.h @@ -120,9 +120,7 @@ static void USB_Device_GetConfiguration(void);
static void USB_Device_GetDescriptor(void);
static void USB_Device_GetStatus(void);
- #if !defined(FEATURELESS_CONTROL_ONLY_DEVICE)
static void USB_Device_ClearSetFeature(void);
- #endif
#endif
#endif
diff --git a/LUFA/Drivers/USB/LowLevel/Endpoint.c b/LUFA/Drivers/USB/LowLevel/Endpoint.c index efa1a2db4..da2925ec7 100644 --- a/LUFA/Drivers/USB/LowLevel/Endpoint.c +++ b/LUFA/Drivers/USB/LowLevel/Endpoint.c @@ -82,6 +82,7 @@ void Endpoint_ClearEndpoints(void) }
}
+#if !defined(CONTROL_ONLY_DEVICE)
uint8_t Endpoint_WaitUntilReady(void)
{
uint16_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;
@@ -289,6 +290,7 @@ uint8_t Endpoint_Read_Stream_BE(void* Buffer, uint16_t Length return ENDPOINT_RWSTREAM_ERROR_NoError;
}
+#endif
uint8_t Endpoint_Write_Control_Stream_LE(const void* Buffer, uint16_t Length)
{
diff --git a/LUFA/Drivers/USB/LowLevel/Endpoint.h b/LUFA/Drivers/USB/LowLevel/Endpoint.h index 172ab33d7..1e88e0658 100644 --- a/LUFA/Drivers/USB/LowLevel/Endpoint.h +++ b/LUFA/Drivers/USB/LowLevel/Endpoint.h @@ -127,14 +127,18 @@ */
#define ENDPOINT_DOUBLEBANK_SUPPORTED(n) _ENDPOINT_GET_DOUBLEBANK(n)
- #if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER) || defined(__DOXYGEN__)
- /** Total number of endpoints (including the default control endpoint at address 0) which may
- * be used in the device. Different USB AVR models support different amounts of endpoints,
- * this value reflects the maximum number of endpoints for the currently selected AVR model.
- */
- #define ENDPOINT_TOTAL_ENDPOINTS 7
+ #if !defined(CONTROL_ONLY_DEVICE)
+ #if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER) || defined(__DOXYGEN__)
+ /** Total number of endpoints (including the default control endpoint at address 0) which may
+ * be used in the device. Different USB AVR models support different amounts of endpoints,
+ * this value reflects the maximum number of endpoints for the currently selected AVR model.
+ */
+ #define ENDPOINT_TOTAL_ENDPOINTS 7
+ #else
+ #define ENDPOINT_TOTAL_ENDPOINTS 5
+ #endif
#else
- #define ENDPOINT_TOTAL_ENDPOINTS 5
+ #define ENDPOINT_TOTAL_ENDPOINTS 1
#endif
/** Interrupt definition for the endpoint SETUP interrupt (for CONTROL type endpoints). Should be
@@ -366,9 +370,17 @@ #define Endpoint_BytesInEndpoint() UEBCLX
#endif
- #define Endpoint_GetCurrentEndpoint() (UENUM & ENDPOINT_EPNUM_MASK)
+ #if !defined(CONTROL_ONLY_DEVICE)
+ #define Endpoint_GetCurrentEndpoint() (UENUM & ENDPOINT_EPNUM_MASK)
+ #else
+ #define Endpoint_GetCurrentEndpoint() ENDPOINT_CONTROLEP
+ #endif
- #define Endpoint_SelectEndpoint(epnum) MACROS{ UENUM = epnum; }MACROE
+ #if !defined(CONTROL_ONLY_DEVICE)
+ #define Endpoint_SelectEndpoint(epnum) MACROS{ UENUM = epnum; }MACROE
+ #else
+ #define Endpoint_SelectEndpoint(epnum) (void)epnum
+ #endif
#define Endpoint_ResetFIFO(epnum) MACROS{ UERST = (1 << epnum); UERST = 0; }MACROE
@@ -378,8 +390,10 @@ #define Endpoint_IsEnabled() ((UECONX & (1 << EPEN)) ? true : false)
- #define Endpoint_IsReadWriteAllowed() ((UEINTX & (1 << RWAL)) ? true : false)
-
+ #if !defined(CONTROL_ONLY_DEVICE)
+ #define Endpoint_IsReadWriteAllowed() ((UEINTX & (1 << RWAL)) ? true : false)
+ #endif
+
#define Endpoint_IsConfigured() ((UESTA0X & (1 << CFGOK)) ? true : false)
#define Endpoint_GetEndpointInterrupts() UEINT
@@ -396,11 +410,19 @@ #define Endpoint_ClearSETUP() MACROS{ UEINTX &= ~(1 << RXSTPI); }MACROE
- #define Endpoint_ClearIN() MACROS{ uint8_t Temp = UEINTX; UEINTX = (Temp & ~(1 << TXINI)); \
- UEINTX = (Temp & ~(1 << FIFOCON)); }MACROE
+ #if !defined(CONTROL_ONLY_DEVICE)
+ #define Endpoint_ClearIN() MACROS{ uint8_t Temp = UEINTX; UEINTX = (Temp & ~(1 << TXINI)); \
+ UEINTX = (Temp & ~(1 << FIFOCON)); }MACROE
+ #else
+ #define Endpoint_ClearIN() MACROS{ UEINTX &= ~(1 << TXINI); }MACROE
+ #endif
- #define Endpoint_ClearOUT() MACROS{ uint8_t Temp = UEINTX; UEINTX = (Temp & ~(1 << RXOUTI)); \
- UEINTX = (Temp & ~(1 << FIFOCON)); }MACROE
+ #if !defined(CONTROL_ONLY_DEVICE)
+ #define Endpoint_ClearOUT() MACROS{ uint8_t Temp = UEINTX; UEINTX = (Temp & ~(1 << RXOUTI)); \
+ UEINTX = (Temp & ~(1 << FIFOCON)); }MACROE
+ #else
+ #define Endpoint_ClearOUT() MACROS{ UEINTX &= ~(1 << RXOUTI); }MACROE
+ #endif
#define Endpoint_StallTransaction() MACROS{ UECONX |= (1 << STALLRQ); }MACROE
@@ -725,6 +747,8 @@ bool Endpoint_ConfigureEndpoint(const uint8_t Number, const uint8_t Type, const uint8_t Direction,
const uint16_t Size, const uint8_t Banks);
+ #if !defined(CONTROL_ONLY_DEVICE)
+
/** Spinloops until the currently selected non-control endpoint is ready for the next packet of data
* to be read or written to it.
*
@@ -870,6 +894,8 @@ #endif
) ATTR_NON_NULL_PTR_ARG(1);
+ #endif
+
/** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in little endian,
* sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared
* in both failure and success states; the user is responsible for manually clearing the setup OUT to
diff --git a/LUFA/Drivers/USB/LowLevel/LowLevel.c b/LUFA/Drivers/USB/LowLevel/LowLevel.c index 4df8eee3b..3994e2f11 100644 --- a/LUFA/Drivers/USB/LowLevel/LowLevel.c +++ b/LUFA/Drivers/USB/LowLevel/LowLevel.c @@ -162,7 +162,7 @@ void USB_ResetInterface(void) USB_RemoteWakeupEnabled = false;
USB_CurrentlySelfPowered = false;
#endif
-
+
if (!(USB_Options & USB_OPT_MANUAL_PLL))
{
#if defined(USB_MODIFIED_FULL_CONTROLLER)
@@ -223,7 +223,12 @@ void USB_ResetInterface(void) #if defined(USB_DEVICE_ONLY)
USB_INT_Enable(USB_INT_SUSPEND);
- USB_INT_Enable(USB_INT_EORSTI);
+ USB_INT_Enable(USB_INT_EORSTI);
+
+ #if defined(CONTROL_ONLY_DEVICE)
+ UENUM = ENDPOINT_CONTROLEP;
+ #endif
+
#elif defined(USB_HOST_ONLY)
USB_Host_HostMode_On();
@@ -240,6 +245,10 @@ void USB_ResetInterface(void) {
USB_INT_Enable(USB_INT_SUSPEND);
USB_INT_Enable(USB_INT_EORSTI);
+
+ #if defined(CONTROL_ONLY_DEVICE)
+ UENUM = ENDPOINT_CONTROLEP;
+ #endif
}
else if (USB_CurrentMode == USB_MODE_HOST)
{
diff --git a/LUFA/MigrationInformation.txt b/LUFA/MigrationInformation.txt index efec274df..9dbabb7e4 100644 --- a/LUFA/MigrationInformation.txt +++ b/LUFA/MigrationInformation.txt @@ -36,6 +36,7 @@ * - The USB_UnhandledControlPacket event no longer has any parameters. User code should no longer attempt to read in the remainder of
* the Control Request header as all Control Request header data is now preloaded by the library and made available in the
* USB_ControlRequest structure.
+ * - The FEATURELESS_CONTROL_ONLY_DEVICE token has been renamed to CONTROL_ONLY_DEVICE.
*
* <b>Host Mode</b>
* - The USB_Host_SendControlRequest() function no longer automatically selects the Control pipe (pipe 0) to allow it to be used on
|