|
|
@ -133,23 +133,17 @@ void StillImage_Task(void)
|
|
|
|
switch (USB_HostState)
|
|
|
|
switch (USB_HostState)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case HOST_STATE_Addressed:
|
|
|
|
case HOST_STATE_Addressed:
|
|
|
|
/* Standard request to set the device configuration to configuration 1 */
|
|
|
|
puts_P(PSTR("Getting Config Data.\r\n"));
|
|
|
|
USB_ControlRequest = (USB_Request_Header_t)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
.bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE),
|
|
|
|
|
|
|
|
.bRequest = REQ_SetConfiguration,
|
|
|
|
|
|
|
|
.wValue = 1,
|
|
|
|
|
|
|
|
.wIndex = 0,
|
|
|
|
|
|
|
|
.wLength = 0,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Select the control pipe for the request transfer */
|
|
|
|
|
|
|
|
Pipe_SelectPipe(PIPE_CONTROLPIPE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Send the request, display error and wait for device detach if request fails */
|
|
|
|
/* Get and process the configuration descriptor data */
|
|
|
|
if (USB_Host_SendControlRequest(NULL) != HOST_SENDCONTROL_Successful)
|
|
|
|
if ((ErrorCode = ProcessConfigurationDescriptor()) != SuccessfulConfigRead)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
puts_P(PSTR("Control error.\r\n"));
|
|
|
|
if (ErrorCode == ControlError)
|
|
|
|
|
|
|
|
puts_P(PSTR("Control Error (Get Configuration).\r\n"));
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
puts_P(PSTR("Invalid Device.\r\n"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf_P(PSTR(" -- Error Code: %d\r\n"), ErrorCode);
|
|
|
|
|
|
|
|
|
|
|
|
/* Indicate error via status LEDs */
|
|
|
|
/* Indicate error via status LEDs */
|
|
|
|
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
|
|
|
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
|
|
@ -159,20 +153,10 @@ void StillImage_Task(void)
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
USB_HostState = HOST_STATE_Configured;
|
|
|
|
/* Set the device configuration to the first configuration (rarely do devices use multiple configurations) */
|
|
|
|
break;
|
|
|
|
if ((ErrorCode = USB_Host_SetDeviceConfiguration(1)) != HOST_SENDCONTROL_Successful)
|
|
|
|
case HOST_STATE_Configured:
|
|
|
|
|
|
|
|
puts_P(PSTR("Getting Config Data.\r\n"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Get and process the configuration descriptor data */
|
|
|
|
|
|
|
|
if ((ErrorCode = ProcessConfigurationDescriptor()) != SuccessfulConfigRead)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (ErrorCode == ControlError)
|
|
|
|
puts_P(PSTR("Control error.\r\n"));
|
|
|
|
puts_P(PSTR("Control Error (Get Configuration).\r\n"));
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
puts_P(PSTR("Invalid Device.\r\n"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf_P(PSTR(" -- Error Code: %d\r\n"), ErrorCode);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Indicate error via status LEDs */
|
|
|
|
/* Indicate error via status LEDs */
|
|
|
|
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
|
|
|
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
|
|
@ -182,6 +166,9 @@ void StillImage_Task(void)
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
USB_HostState = HOST_STATE_Configured;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HOST_STATE_Configured:
|
|
|
|
puts_P(PSTR("Still Image Device Enumerated.\r\n"));
|
|
|
|
puts_P(PSTR("Still Image Device Enumerated.\r\n"));
|
|
|
|
|
|
|
|
|
|
|
|
USB_HostState = HOST_STATE_Ready;
|
|
|
|
USB_HostState = HOST_STATE_Ready;
|
|
|
|