Added new USB_Host_GetDeviceDescriptor() convenience function to retrieve the attached device's Device descriptor.
Make Pipe_ConfigurePipe() mask the given endpoint number against PIPE_EPNUM_MASK to ensure the endpoint IN direction bit is cleared to prevent endpoint type corruption.
Fix documentation mentioning Pipe_GetCurrentToken() function when real name is Pipe_GetPipeToken().
CFLAGS += -fpack-struct\r
CFLAGS += -fshort-enums\r
CFLAGS += -fno-inline-small-functions\r
-CFLAGS += -fno-reorder-blocks\r
-CFLAGS += -fno-reorder-blocks-and-partition\r
-CFLAGS += -fno-reorder-functions\r
-CFLAGS += -fno-toplevel-reorder\r
CFLAGS += -Wall\r
CFLAGS += -Wstrict-prototypes\r
CFLAGS += -Wundef\r
CFLAGS += -fpack-struct\r
CFLAGS += -fshort-enums\r
CFLAGS += -fno-inline-small-functions\r
-CFLAGS += -fno-reorder-blocks\r
-CFLAGS += -fno-reorder-blocks-and-partition\r
-CFLAGS += -fno-reorder-functions\r
-CFLAGS += -fno-toplevel-reorder\r
CFLAGS += -Wall\r
CFLAGS += -Wstrict-prototypes\r
CFLAGS += -Wundef\r
CFLAGS += -fpack-struct\r
CFLAGS += -fshort-enums\r
CFLAGS += -fno-inline-small-functions\r
-CFLAGS += -fno-reorder-blocks\r
-CFLAGS += -fno-reorder-blocks-and-partition\r
-CFLAGS += -fno-reorder-functions\r
-CFLAGS += -fno-toplevel-reorder\r
CFLAGS += -Wall\r
CFLAGS += -Wstrict-prototypes\r
CFLAGS += -Wundef\r
if (Pipe_IsStalled())\r
{\r
/* Clear the stall condition on the OUT pipe */\r
- MassStore_ClearPipeStall(MASS_STORE_DATA_OUT_PIPE);\r
+ USB_Host_ClearPipeStall(MASS_STORE_DATA_OUT_PIPE);\r
\r
return PIPE_RWSTREAM_PipeStalled;\r
}\r
if (Pipe_IsStalled())\r
{\r
/* Clear the stall condition on the IN pipe */\r
- MassStore_ClearPipeStall(MASS_STORE_DATA_IN_PIPE);\r
+ USB_Host_ClearPipeStall(MASS_STORE_DATA_IN_PIPE);\r
\r
return PIPE_RWSTREAM_PipeStalled;\r
}\r
static uint8_t MassStore_GetReturnedStatus(void);\r
#endif\r
\r
- uint8_t MassStore_ClearPipeStall(const uint8_t EndpointNum);\r
uint8_t MassStore_MassStorageReset(void);\r
uint8_t MassStore_GetMaxLUN(uint8_t* const MaxLUNIndex);\r
uint8_t MassStore_RequestSense(const uint8_t LUNIndex, const SCSI_Request_Sense_Response_t* const SensePtr)\r
}\r
\r
puts_P(PSTR("Bluetooth Dongle Detected.\r\n"));\r
-\r
- /* Standard request to set the device configuration to configuration 1 */\r
- USB_ControlRequest = (USB_Request_Header_t)\r
- {\r
- bmRequestType: (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE),\r
- bRequest: REQ_SetConfiguration,\r
- wValue: 1,\r
- wIndex: 0,\r
- wLength: 0,\r
- };\r
\r
/* Select the control pipe for the request transfer */\r
Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
\r
- /* Send the request, display error and wait for device detatch if request fails */\r
- if ((ErrorCode = USB_Host_SendControlRequest(NULL)) != HOST_SENDCONTROL_Successful)\r
+ /* Set the device configuration to the first configuration (rarely do devices use multiple configurations) */\r
+ if ((ErrorCode = USB_Host_SetDeviceConfiguration(1)) != HOST_SENDCONTROL_Successful)\r
{\r
puts_P(PSTR("Control Error (Set Configuration).\r\n"));\r
printf_P(PSTR(" -- Error Code: %d\r\n"), ErrorCode);\r
if (Pipe_IsStalled())\r
{\r
/* Clear the stall condition on the OUT pipe */\r
- MassStore_ClearPipeStall(MASS_STORE_DATA_OUT_PIPE);\r
+ USB_Host_ClearPipeStall(MASS_STORE_DATA_OUT_PIPE);\r
\r
return PIPE_RWSTREAM_PipeStalled;\r
}\r
if (Pipe_IsStalled())\r
{\r
/* Clear the stall condition on the IN pipe */\r
- MassStore_ClearPipeStall(MASS_STORE_DATA_IN_PIPE);\r
+ USB_Host_ClearPipeStall(MASS_STORE_DATA_IN_PIPE);\r
\r
return PIPE_RWSTREAM_PipeStalled;\r
}\r
return PIPE_RWSTREAM_NoError;\r
}\r
\r
-/** Clears the stall condition in the attached device on the nominated endpoint number.\r
- *\r
- * \param EndpointNum Endpoint number in the attached device whose stall condition is to be cleared\r
- *\r
- * \return A value from the USB_Host_SendControlErrorCodes_t enum\r
- */\r
-uint8_t MassStore_ClearPipeStall(const uint8_t EndpointNum)\r
-{\r
- USB_ControlRequest = (USB_Request_Header_t)\r
- {\r
- .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_ENDPOINT),\r
- .bRequest = REQ_ClearFeature,\r
- .wValue = FEATURE_ENDPOINT_HALT,\r
- .wIndex = EndpointNum,\r
- .wLength = 0,\r
- };\r
- \r
- /* Select the control pipe for the request transfer */\r
- Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
-\r
- return USB_Host_SendControlRequest(NULL);\r
-}\r
-\r
/** Issues a Mass Storage class specific request to reset the attached device's Mass Storage interface,\r
* readying the device for the next CBW.\r
*\r
static uint8_t MassStore_GetReturnedStatus(void);\r
#endif\r
\r
- uint8_t MassStore_ClearPipeStall(const uint8_t EndpointNum);\r
uint8_t MassStore_MassStorageReset(void);\r
uint8_t MassStore_GetMaxLUN(uint8_t* const MaxLUNIndex);\r
uint8_t MassStore_RequestSense(const uint8_t LUNIndex, const SCSI_Request_Sense_Response_t* const SensePtr)\r
*\r
* \note This global is only present if the user application can be a USB host.\r
*\r
+ * \see \ref USB_Host_States_t for a list of possible host states\r
+ *\r
* \ingroup Group_Host\r
*/\r
extern volatile uint8_t USB_HostState;\r
return USB_Host_SendControlRequest(NULL);\r
}\r
\r
+uint8_t USB_Host_GetDeviceDescriptor(USB_Descriptor_Device_t* DeviceDescriptorPtr)\r
+{\r
+ USB_ControlRequest = (USB_Request_Header_t)\r
+ {\r
+ bmRequestType: (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE),\r
+ bRequest: REQ_GetDescriptor,\r
+ wValue: (DTYPE_Device << 8),\r
+ wIndex: 0,\r
+ wLength: sizeof(USB_Descriptor_Device_t),\r
+ };\r
+\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+ \r
+ return USB_Host_SendControlRequest(DeviceDescriptorPtr);\r
+}\r
+\r
+uint8_t USB_Host_ClearPipeStall(uint8_t EndpointNum)\r
+{\r
+ if (Pipe_GetPipeToken() == PIPE_TOKEN_IN)\r
+ EndpointNum |= (1 << 7);\r
+\r
+ USB_ControlRequest = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_ENDPOINT),\r
+ .bRequest = REQ_ClearFeature,\r
+ .wValue = FEATURE_ENDPOINT_HALT,\r
+ .wIndex = EndpointNum,\r
+ .wLength = 0,\r
+ };\r
+\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+ \r
+ return USB_Host_SendControlRequest(NULL);\r
+}\r
+\r
#endif\r
\r
#include "../../../Common/Common.h"\r
#include "../HighLevel/USBInterrupt.h"\r
+ #include "../HighLevel/StdDescriptors.h"\r
+ #include "Pipe.h"\r
\r
/* Enable C linkage for C++ Compilers: */\r
#if defined(__cplusplus)\r
* \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.\r
*/\r
uint8_t USB_Host_SetDeviceConfiguration(uint8_t ConfigNumber);\r
+ \r
+ /** Convenience function. This routine sends a GetDescriptor standard request to the attached\r
+ * device, requesting the device descriptor. This can be used to easily retrieve information\r
+ * about the device such as its VID, PID and power requirements.\r
+ *\r
+ * \note After this routine returns, the control pipe will be selected.\r
+ *\r
+ * \param DeviceDescriptorPtr Pointer to the destination device descriptor structure where\r
+ * the read data is to be stored\r
+ *\r
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.\r
+ */\r
+ uint8_t USB_Host_GetDeviceDescriptor(USB_Descriptor_Device_t* DeviceDescriptorPtr);\r
+ \r
+ /** Clears a stall condition on the given pipe, via a ClearFeature request to the attached device.\r
+ *\r
+ * \note After this routine returns, the control pipe will be selected.\r
+ *\r
+ * \param EndpointIndex Index of the endpoint to clear\r
+ *\r
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.\r
+ */ \r
+ uint8_t USB_Host_ClearPipeStall(uint8_t EndpointIndex);\r
\r
/* Enums: */\r
/** Enum for the various states of the USB Host state machine. Only some states are\r
\r
UPCFG1X = 0;\r
\r
- UPCFG0X = ((Type << EPTYPE0) | Token | (EndpointNumber << PEPNUM0));\r
+ UPCFG0X = ((Type << EPTYPE0) | Token | ((EndpointNumber & PIPE_EPNUM_MASK) << PEPNUM0));\r
UPCFG1X = ((1 << ALLOC) | Banks | Pipe_BytesToEPSizeMask(Size));\r
\r
return Pipe_IsConfigured();\r
*\r
* \return The current pipe token, as a PIPE_TOKEN_* mask\r
*/\r
- static inline uint8_t Pipe_GetCurrentToken(void);\r
+ static inline uint8_t Pipe_GetPipeToken(void);\r
\r
/** Sets the token for the currently selected pipe to one of the tokens specified by the PIPE_TOKEN_*\r
* masks. This can be used on CONTROL type pipes, to allow for bidirectional transfer of data during\r
* internal control\r
* - Added new USB_Host_SetDeviceConfiguration() convenience function for easy configuration selection of devices while in USB\r
* host mode\r
+ * - Added new USB_Host_ClearPipeStall() convenience function to clear a stall condition on an attached device's endpoint\r
+ * - Added new USB_Host_GetDeviceDescriptor() convenience function to retrieve the attached device's Device descriptor\r
* - Added USB Missle Launcher project, submitted by Dave Fletcher\r
* - Pipe_GetErrorFlags() now returns additional error flags for overflow and underflow errors\r
+ * - Make Pipe_ConfigurePipe() mask the given endpoint number against PIPE_EPNUM_MASK to ensure the endpoint IN direction bit is\r
+ * cleared to prevent endpoint type corruption\r
+ * - Fix documentation mentioning Pipe_GetCurrentToken() function when real name is Pipe_GetPipeToken()\r
*\r
*\r
* \section Sec_ChangeLog090605 Version 090605\r
* - Port LUFA to the Atmel ARM7 series microcontrollers\r
* - Remake AVRStudio project files\r
* - Master LUFA include file\r
+ * - Debug mode for pipe/endpoint calls\r
+ * - Device descriptor get routines\r
+ * - Add ClearPipeStall host function\r
*/\r