X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/3dce79d68ccc50ee1007e485396826762b6965b5..18b0d408a9e68cbc1ce36da89d74a799d7fc31de:/Demos/Host/ClassDriver/StillImageHost/StillImageHost.c diff --git a/Demos/Host/ClassDriver/StillImageHost/StillImageHost.c b/Demos/Host/ClassDriver/StillImageHost/StillImageHost.c index 2f0e5a2d1..fb3a78448 100644 --- a/Demos/Host/ClassDriver/StillImageHost/StillImageHost.c +++ b/Demos/Host/ClassDriver/StillImageHost/StillImageHost.c @@ -45,14 +45,18 @@ USB_ClassInfo_SI_Host_t DigitalCamera_SI_Interface = .Config = { .DataINPipeNumber = 1, + .DataINPipeDoubleBank = false, + .DataOUTPipeNumber = 2, + .DataOUTPipeDoubleBank = false, + .EventsPipeNumber = 3, + .EventsPipeDoubleBank = false, }, }; - /** Main program entry point. This routine configures the hardware required by the application, then - * starts the scheduler to run the application tasks. + * enters a loop to run the application tasks in sequence. */ int main(void) { @@ -72,9 +76,8 @@ int main(void) uint16_t ConfigDescriptorSize; uint8_t ConfigDescriptorData[512]; - if ((USB_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, NULL) != HOST_SENDCONTROL_Successful) || - (ConfigDescriptorSize > sizeof(ConfigDescriptorData)) || - (USB_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData))) + if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData, + sizeof(ConfigDescriptorData)) != HOST_GETCONFIG_Successful) { printf("Error Retrieving Configuration Descriptor.\r\n"); LEDs_SetAllLEDs(LEDMASK_USB_ERROR); @@ -82,8 +85,8 @@ int main(void) break; } - if (SI_Host_ConfigurePipes(&DigitalCamera_SI_Interface, - ConfigDescriptorSize, ConfigDescriptorData) != SI_ENUMERROR_NoError) + if (SImage_Host_ConfigurePipes(&DigitalCamera_SI_Interface, + ConfigDescriptorSize, ConfigDescriptorData) != SI_ENUMERROR_NoError) { printf("Attached Device Not a Valid CDC Class Device.\r\n"); LEDs_SetAllLEDs(LEDMASK_USB_ERROR); @@ -103,11 +106,42 @@ int main(void) USB_HostState = HOST_STATE_Configured; break; case HOST_STATE_Configured: - + printf("Opening Session...\r\n"); + + if (SImage_Host_OpenSession(&DigitalCamera_SI_Interface) != PIPE_RWSTREAM_NoError) + { + printf("Could not open PIMA session.\r\n"); + USB_HostState = HOST_STATE_WaitForDeviceRemoval; + break; + } + + printf("Turning off Device...\r\n"); + + SImage_Host_SendCommand(&DigitalCamera_SI_Interface, 0x1013, 0, NULL); + if (SImage_Host_ReceiveResponse(&DigitalCamera_SI_Interface)) + { + printf("Could not turn off device.\r\n"); + USB_HostState = HOST_STATE_WaitForDeviceRemoval; + break; + } + + printf("Device Off.\r\n"); + + printf("Closing Session...\r\n"); + + if (SImage_Host_CloseSession(&DigitalCamera_SI_Interface) != PIPE_RWSTREAM_NoError) + { + printf("Could not close PIMA session.\r\n"); + USB_HostState = HOST_STATE_WaitForDeviceRemoval; + break; + } + + LEDs_SetAllLEDs(LEDMASK_USB_READY); + USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - SI_Host_USBTask(&DigitalCamera_SI_Interface); + SImage_Host_USBTask(&DigitalCamera_SI_Interface); USB_USBTask(); } }