Add new USB_Host_SetInterfaceAltSetting() convenience function.

pull/1469/head
Dean Camera 14 years ago
parent 348bf33b18
commit cc9b190919

@ -177,16 +177,7 @@ void USB_Printer_Host(void)
* request to switch to the interface alternate setting with the Bidirectional protocol */ * request to switch to the interface alternate setting with the Bidirectional protocol */
if (PrinterAltSetting) if (PrinterAltSetting)
{ {
USB_ControlRequest = (USB_Request_Header_t) if ((ErrorCode = USB_Host_SetInterfaceAltSetting(PrinterInterfaceNumber, PrinterAltSetting)) != HOST_SENDCONTROL_Successful)
{
.bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_INTERFACE),
.bRequest = REQ_SetInterface,
.wValue = PrinterAltSetting,
.wIndex = PrinterInterfaceNumber,
.wLength = 0,
};
if ((ErrorCode = USB_Host_SendControlRequest(NULL)) != HOST_SENDCONTROL_Successful)
{ {
printf_P(PSTR(ESC_FG_RED "Control Error (Set Interface).\r\n" printf_P(PSTR(ESC_FG_RED "Control Error (Set Interface).\r\n"
" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode); " -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode);

@ -181,20 +181,12 @@ uint8_t PRNT_Host_SetBidirectionalMode(USB_ClassInfo_PRNT_Host_t* const PRNTInte
{ {
uint8_t ErrorCode; uint8_t ErrorCode;
USB_ControlRequest = (USB_Request_Header_t) if ((ErrorCode = USB_Host_SetInterfaceAltSetting(PRNTInterfaceInfo->State.InterfaceNumber,
PRNTInterfaceInfo->State.AlternateSetting)) != HOST_SENDCONTROL_Successful)
{ {
.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; return ErrorCode;
} }
}
return HOST_SENDCONTROL_Successful; return HOST_SENDCONTROL_Successful;
} }

@ -351,5 +351,22 @@ uint8_t USB_Host_ClearPipeStall(const uint8_t EndpointNum)
return USB_Host_SendControlRequest(NULL); 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 #endif

@ -330,6 +330,19 @@
*/ */
uint8_t USB_Host_ClearPipeStall(const uint8_t EndpointIndex); 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: */ /* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__) #if !defined(__DOXYGEN__)
/* Macros: */ /* Macros: */

@ -351,5 +351,22 @@ uint8_t USB_Host_ClearPipeStall(const uint8_t EndpointNum)
return USB_Host_SendControlRequest(NULL); 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 #endif

@ -331,6 +331,19 @@
*/ */
uint8_t USB_Host_ClearPipeStall(const uint8_t EndpointIndex); 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: */ /* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__) #if !defined(__DOXYGEN__)
/* Macros: */ /* Macros: */

@ -11,7 +11,7 @@
* - Core: * - Core:
* - Added USE_LUFA_CONFIG_HEADER compile time option to include a LUFAConfig.h header in the user director for LUFA configuration * - Added USE_LUFA_CONFIG_HEADER compile time option to include a LUFAConfig.h header in the user director for LUFA configuration
* tokens as an alternative to tokens defined in the project makefile * tokens as an alternative to tokens defined in the project makefile
* - Added new RNDIS Device Classs Driver packet send and receive functions * - Added new USB_Host_SetInterfaceAltSetting() convenience function for the selection of an interface's alternative setting
* - Library Applications: * - Library Applications:
* - Added new MediaControl project * - Added new MediaControl project
* - Added new incomplete AndroidAccessoryHost Host LowLevel demo * - Added new incomplete AndroidAccessoryHost Host LowLevel demo
@ -50,6 +50,7 @@
* - Internal restructuring for eventual multiple architecture ports * - Internal restructuring for eventual multiple architecture ports
* - Added AVR32 UC3 architecture port (currently incomplete/experimental) * - Added AVR32 UC3 architecture port (currently incomplete/experimental)
* - Added new architecture independant functions to enable, disable, save and restore the Global Interrupt Enable flags * - Added new architecture independant functions to enable, disable, save and restore the Global Interrupt Enable flags
* - Added new RNDIS Device Classs Driver packet send and receive functions
* - Library Applications: * - Library Applications:
* - Added ability to write protect Mass Storage disk write operations from the host OS * - Added ability to write protect Mass Storage disk write operations from the host OS
* - Added new MIDIToneGenerator project * - Added new MIDIToneGenerator project

Loading…
Cancel
Save