diff options
Diffstat (limited to 'LUFA/Drivers')
-rw-r--r-- | LUFA/Drivers/USB/HighLevel/USBTask.h | 2 | ||||
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/Host.c | 35 | ||||
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/Host.h | 25 | ||||
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/Pipe.c | 2 | ||||
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/Pipe.h | 2 |
5 files changed, 64 insertions, 2 deletions
diff --git a/LUFA/Drivers/USB/HighLevel/USBTask.h b/LUFA/Drivers/USB/HighLevel/USBTask.h index e4c8a02ae..2a9bf1953 100644 --- a/LUFA/Drivers/USB/HighLevel/USBTask.h +++ b/LUFA/Drivers/USB/HighLevel/USBTask.h @@ -116,6 +116,8 @@ *
* \note This global is only present if the user application can be a USB host.
*
+ * \see \ref USB_Host_States_t for a list of possible host states
+ *
* \ingroup Group_Host
*/
extern volatile uint8_t USB_HostState;
diff --git a/LUFA/Drivers/USB/LowLevel/Host.c b/LUFA/Drivers/USB/LowLevel/Host.c index c059b43ac..421719bf8 100644 --- a/LUFA/Drivers/USB/LowLevel/Host.c +++ b/LUFA/Drivers/USB/LowLevel/Host.c @@ -302,4 +302,39 @@ uint8_t USB_Host_SetDeviceConfiguration(uint8_t ConfigNumber) return USB_Host_SendControlRequest(NULL);
}
+uint8_t USB_Host_GetDeviceDescriptor(USB_Descriptor_Device_t* DeviceDescriptorPtr)
+{
+ USB_ControlRequest = (USB_Request_Header_t)
+ {
+ bmRequestType: (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE),
+ bRequest: REQ_GetDescriptor,
+ wValue: (DTYPE_Device << 8),
+ wIndex: 0,
+ wLength: sizeof(USB_Descriptor_Device_t),
+ };
+
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);
+
+ return USB_Host_SendControlRequest(DeviceDescriptorPtr);
+}
+
+uint8_t USB_Host_ClearPipeStall(uint8_t EndpointNum)
+{
+ if (Pipe_GetPipeToken() == PIPE_TOKEN_IN)
+ EndpointNum |= (1 << 7);
+
+ USB_ControlRequest = (USB_Request_Header_t)
+ {
+ .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_ENDPOINT),
+ .bRequest = REQ_ClearFeature,
+ .wValue = FEATURE_ENDPOINT_HALT,
+ .wIndex = EndpointNum,
+ .wLength = 0,
+ };
+
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);
+
+ return USB_Host_SendControlRequest(NULL);
+}
+
#endif
diff --git a/LUFA/Drivers/USB/LowLevel/Host.h b/LUFA/Drivers/USB/LowLevel/Host.h index 7130c7579..2a40a1dbc 100644 --- a/LUFA/Drivers/USB/LowLevel/Host.h +++ b/LUFA/Drivers/USB/LowLevel/Host.h @@ -47,6 +47,8 @@ #include "../../../Common/Common.h"
#include "../HighLevel/USBInterrupt.h"
+ #include "../HighLevel/StdDescriptors.h"
+ #include "Pipe.h"
/* Enable C linkage for C++ Compilers: */
#if defined(__cplusplus)
@@ -185,6 +187,29 @@ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.
*/
uint8_t USB_Host_SetDeviceConfiguration(uint8_t ConfigNumber);
+
+ /** Convenience function. This routine sends a GetDescriptor standard request to the attached
+ * device, requesting the device descriptor. This can be used to easily retrieve information
+ * about the device such as its VID, PID and power requirements.
+ *
+ * \note After this routine returns, the control pipe will be selected.
+ *
+ * \param DeviceDescriptorPtr Pointer to the destination device descriptor structure where
+ * the read data is to be stored
+ *
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.
+ */
+ uint8_t USB_Host_GetDeviceDescriptor(USB_Descriptor_Device_t* DeviceDescriptorPtr);
+
+ /** Clears a stall condition on the given pipe, via a ClearFeature request to the attached device.
+ *
+ * \note After this routine returns, the control pipe will be selected.
+ *
+ * \param EndpointIndex Index of the endpoint to clear
+ *
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.
+ */
+ uint8_t USB_Host_ClearPipeStall(uint8_t EndpointIndex);
/* Enums: */
/** Enum for the various states of the USB Host state machine. Only some states are
diff --git a/LUFA/Drivers/USB/LowLevel/Pipe.c b/LUFA/Drivers/USB/LowLevel/Pipe.c index 3c493fe5a..189aaa63b 100644 --- a/LUFA/Drivers/USB/LowLevel/Pipe.c +++ b/LUFA/Drivers/USB/LowLevel/Pipe.c @@ -45,7 +45,7 @@ bool Pipe_ConfigurePipe(const uint8_t Number, const uint8_t Type, const uint8_t UPCFG1X = 0;
- UPCFG0X = ((Type << EPTYPE0) | Token | (EndpointNumber << PEPNUM0));
+ UPCFG0X = ((Type << EPTYPE0) | Token | ((EndpointNumber & PIPE_EPNUM_MASK) << PEPNUM0));
UPCFG1X = ((1 << ALLOC) | Banks | Pipe_BytesToEPSizeMask(Size));
return Pipe_IsConfigured();
diff --git a/LUFA/Drivers/USB/LowLevel/Pipe.h b/LUFA/Drivers/USB/LowLevel/Pipe.h index 62cbe65a2..82d9b69d4 100644 --- a/LUFA/Drivers/USB/LowLevel/Pipe.h +++ b/LUFA/Drivers/USB/LowLevel/Pipe.h @@ -219,7 +219,7 @@ *
* \return The current pipe token, as a PIPE_TOKEN_* mask
*/
- static inline uint8_t Pipe_GetCurrentToken(void);
+ static inline uint8_t Pipe_GetPipeToken(void);
/** Sets the token for the currently selected pipe to one of the tokens specified by the PIPE_TOKEN_*
* masks. This can be used on CONTROL type pipes, to allow for bidirectional transfer of data during
|