diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2011-05-27 07:33:58 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2011-05-27 07:33:58 +0000 |
commit | cc9b190919abbc567cd179b31afeef565efb1f17 (patch) | |
tree | 8623481832f9a5a53eec5f49f712ca383732cba7 /LUFA/Drivers | |
parent | 348bf33b189b6dfa2d62170331ed6402b986ee59 (diff) | |
download | lufa-cc9b190919abbc567cd179b31afeef565efb1f17.tar.gz lufa-cc9b190919abbc567cd179b31afeef565efb1f17.tar.bz2 lufa-cc9b190919abbc567cd179b31afeef565efb1f17.zip |
Add new USB_Host_SetInterfaceAltSetting() convenience function.
Diffstat (limited to 'LUFA/Drivers')
-rw-r--r-- | LUFA/Drivers/USB/Class/Host/Printer.c | 18 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c | 17 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Core/AVR8/Host_AVR8.h | 13 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Core/UC3/Host_UC3.c | 17 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Core/UC3/Host_UC3.h | 13 |
5 files changed, 65 insertions, 13 deletions
diff --git a/LUFA/Drivers/USB/Class/Host/Printer.c b/LUFA/Drivers/USB/Class/Host/Printer.c index 278df2e3f..290393ac5 100644 --- a/LUFA/Drivers/USB/Class/Host/Printer.c +++ b/LUFA/Drivers/USB/Class/Host/Printer.c @@ -181,19 +181,11 @@ uint8_t PRNT_Host_SetBidirectionalMode(USB_ClassInfo_PRNT_Host_t* const PRNTInte { uint8_t ErrorCode; - USB_ControlRequest = (USB_Request_Header_t) - { - .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_INTERFACE), - .bRequest = REQ_SetInterface, - .wValue = PRNTInterfaceInfo->State.AlternateSetting, - .wIndex = PRNTInterfaceInfo->State.InterfaceNumber, - .wLength = 0, - }; - - Pipe_SelectPipe(PIPE_CONTROLPIPE); - - if ((ErrorCode = USB_Host_SendControlRequest(NULL)) != HOST_SENDCONTROL_Successful) - return ErrorCode; + if ((ErrorCode = USB_Host_SetInterfaceAltSetting(PRNTInterfaceInfo->State.InterfaceNumber, + PRNTInterfaceInfo->State.AlternateSetting)) != HOST_SENDCONTROL_Successful) + { + return ErrorCode; + } } return HOST_SENDCONTROL_Successful; diff --git a/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c b/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c index 6c45265d7..d18e023c7 100644 --- a/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c +++ b/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c @@ -351,5 +351,22 @@ uint8_t USB_Host_ClearPipeStall(const uint8_t EndpointNum) return USB_Host_SendControlRequest(NULL); } +uint8_t USB_Host_SetInterfaceAltSetting(const uint8_t InterfaceNum, + const uint8_t AltSetting) +{ + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_INTERFACE), + .bRequest = REQ_SetInterface, + .wValue = AltSetting, + .wIndex = InterfaceNum, + .wLength = 0, + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + return USB_Host_SendControlRequest(NULL); +} + #endif diff --git a/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.h b/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.h index 836c83b67..58d980442 100644 --- a/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.h +++ b/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.h @@ -330,6 +330,19 @@ */ uint8_t USB_Host_ClearPipeStall(const uint8_t EndpointIndex); + /** Selects a given alternative setting for the specfied interface, via a SET INTERFACE standard request to + * the attached device. + * + * \note After this routine returns, the control pipe will be selected. + * + * \param[in] InterfaceIndex Index of the interface whose alternative setting is to be altered. + * \param[in] AltSetting Index of the interface's alternative setting which is to be selected. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. + */ + uint8_t USB_Host_SetInterfaceAltSetting(const uint8_t InterfaceNum, + const uint8_t AltSetting); + /* Private Interface - For use in library only: */ #if !defined(__DOXYGEN__) /* Macros: */ diff --git a/LUFA/Drivers/USB/Core/UC3/Host_UC3.c b/LUFA/Drivers/USB/Core/UC3/Host_UC3.c index 88a7df5c4..02cb1e68e 100644 --- a/LUFA/Drivers/USB/Core/UC3/Host_UC3.c +++ b/LUFA/Drivers/USB/Core/UC3/Host_UC3.c @@ -351,5 +351,22 @@ uint8_t USB_Host_ClearPipeStall(const uint8_t EndpointNum) return USB_Host_SendControlRequest(NULL);
}
+uint8_t USB_Host_SetInterfaceAltSetting(const uint8_t InterfaceNum,
+ const uint8_t AltSetting)
+{
+ USB_ControlRequest = (USB_Request_Header_t)
+ {
+ .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_INTERFACE),
+ .bRequest = REQ_SetInterface,
+ .wValue = AltSetting,
+ .wIndex = InterfaceNum,
+ .wLength = 0,
+ };
+
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);
+
+ return USB_Host_SendControlRequest(NULL);
+}
+
#endif
diff --git a/LUFA/Drivers/USB/Core/UC3/Host_UC3.h b/LUFA/Drivers/USB/Core/UC3/Host_UC3.h index 6040eb32b..c5dfe76fd 100644 --- a/LUFA/Drivers/USB/Core/UC3/Host_UC3.h +++ b/LUFA/Drivers/USB/Core/UC3/Host_UC3.h @@ -331,6 +331,19 @@ */
uint8_t USB_Host_ClearPipeStall(const uint8_t EndpointIndex);
+ /** Selects a given alternative setting for the specfied interface, via a SET INTERFACE standard request to
+ * the attached device.
+ *
+ * \note After this routine returns, the control pipe will be selected.
+ *
+ * \param[in] InterfaceIndex Index of the interface whose alternative setting is to be altered.
+ * \param[in] AltSetting Index of the interface's alternative setting which is to be selected.
+ *
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.
+ */
+ uint8_t USB_Host_SetInterfaceAltSetting(const uint8_t InterfaceNum,
+ const uint8_t AltSetting);
+
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
/* Macros: */
|