X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/6933f2e1a543b066ebe734bd126a7ff2f1c2777f..2ee9fc707784e115d744dbc229bdc893f4bb6bc1:/Demos/Host/StillImageHost/StillImageHost.c?ds=inline diff --git a/Demos/Host/StillImageHost/StillImageHost.c b/Demos/Host/StillImageHost/StillImageHost.c index 787629c3b..197e832f6 100644 --- a/Demos/Host/StillImageHost/StillImageHost.c +++ b/Demos/Host/StillImageHost/StillImageHost.c @@ -36,16 +36,11 @@ #include "StillImageHost.h" -/* Project Tags, for reading out using the ButtLoad project */ -BUTTLOADTAG(ProjName, "LUFA SIMG Host App"); -BUTTLOADTAG(BuildTime, __TIME__); -BUTTLOADTAG(BuildDate, __DATE__); - /* Scheduler Task List */ TASK_LIST { - { Task: USB_USBTask , TaskStatus: TASK_STOP }, - { Task: USB_SImage_Host , TaskStatus: TASK_STOP }, + { .Task = USB_USBTask , .TaskStatus = TASK_STOP }, + { .Task = USB_SImage_Host , .TaskStatus = TASK_STOP }, }; @@ -86,7 +81,7 @@ int main(void) /** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and * starts the library USB task to begin the enumeration and USB management process. */ -EVENT_HANDLER(USB_DeviceAttached) +void EVENT_USB_DeviceAttached(void) { puts_P(PSTR("Device Attached.\r\n")); UpdateStatus(Status_USBEnumerating); @@ -98,7 +93,7 @@ EVENT_HANDLER(USB_DeviceAttached) /** Event handler for the USB_DeviceUnattached event. This indicates that a device has been removed from the host, and * stops the library USB task management process. */ -EVENT_HANDLER(USB_DeviceUnattached) +void EVENT_USB_DeviceUnattached(void) { /* Stop USB management and Still Image tasks */ Scheduler_SetTaskMode(USB_USBTask, TASK_STOP); @@ -111,7 +106,7 @@ EVENT_HANDLER(USB_DeviceUnattached) /** Event handler for the USB_DeviceEnumerationComplete event. This indicates that a device has been successfully * enumerated by the host and is now ready to be used by the application. */ -EVENT_HANDLER(USB_DeviceEnumerationComplete) +void EVENT_USB_DeviceEnumerationComplete(void) { /* Once device is fully enumerated, start the Still Image Host task */ Scheduler_SetTaskMode(USB_SImage_Host, TASK_RUN); @@ -121,7 +116,7 @@ EVENT_HANDLER(USB_DeviceEnumerationComplete) } /** Event handler for the USB_HostError event. This indicates that a hardware error occurred while in host mode. */ -EVENT_HANDLER(USB_HostError) +void EVENT_USB_HostError(const uint8_t ErrorCode) { USB_ShutDown(); @@ -135,7 +130,7 @@ EVENT_HANDLER(USB_HostError) /** Event handler for the USB_DeviceEnumerationFailed event. This indicates that a problem occurred while * enumerating an attached USB device. */ -EVENT_HANDLER(USB_DeviceEnumerationFailed) +void EVENT_USB_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode) { puts_P(PSTR(ESC_BG_RED "Dev Enum Error\r\n")); printf_P(PSTR(" -- Error Code %d\r\n"), ErrorCode); @@ -156,15 +151,18 @@ TASK(USB_SImage_Host) { case HOST_STATE_Addressed: /* Standard request to set the device configuration to configuration 1 */ - USB_HostRequest = (USB_Host_Request_Header_t) + USB_ControlRequest = (USB_Request_Header_t) { - bmRequestType: (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE), - bRequest: REQ_SetConfiguration, - wValue: 1, - wIndex: 0, - wLength: 0, + .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 */ if (USB_Host_SendControlRequest(NULL) != HOST_SENDCONTROL_Successful) { @@ -213,18 +211,18 @@ TASK(USB_SImage_Host) PIMA_SendBlock = (PIMA_Container_t) { - DataLength: PIMA_COMMAND_SIZE(0), - Type: CType_CommandBlock, - Code: PIMA_OPERATION_GETDEVICEINFO, - TransactionID: 0x00000000, - Params: {}, + .DataLength = PIMA_COMMAND_SIZE(0), + .Type = CType_CommandBlock, + .Code = PIMA_OPERATION_GETDEVICEINFO, + .TransactionID = 0x00000000, + .Params = {}, }; /* Send the GETDEVICEINFO block */ SImage_SendBlockHeader(); /* Receive the response data block */ - if ((ErrorCode = SImage_RecieveBlockHeader()) != PIPE_RWSTREAM_ERROR_NoError) + if ((ErrorCode = SImage_RecieveBlockHeader()) != PIPE_RWSTREAM_NoError) { ShowCommandError(ErrorCode, false); break; @@ -240,7 +238,7 @@ TASK(USB_SImage_Host) SImage_ReadData(DeviceInfo, DeviceInfoSize); /* Once all the data has been read, the pipe must be cleared before the response can be sent */ - Pipe_ClearCurrentBank(); + Pipe_ClearIN(); /* Create a pointer for walking through the info dataset */ uint8_t* DeviceInfoPos = DeviceInfo; @@ -275,7 +273,7 @@ TASK(USB_SImage_Host) printf_P(PSTR(" Device Version: %s\r\n"), DeviceVersion); /* Receive the final response block from the device */ - if ((ErrorCode = SImage_RecieveBlockHeader()) != PIPE_RWSTREAM_ERROR_NoError) + if ((ErrorCode = SImage_RecieveBlockHeader()) != PIPE_RWSTREAM_NoError) { ShowCommandError(ErrorCode, false); break; @@ -292,18 +290,18 @@ TASK(USB_SImage_Host) PIMA_SendBlock = (PIMA_Container_t) { - DataLength: PIMA_COMMAND_SIZE(1), - Type: CType_CommandBlock, - Code: PIMA_OPERATION_OPENSESSION, - TransactionID: 0x00000000, - Params: {0x00000001}, + .DataLength = PIMA_COMMAND_SIZE(1), + .Type = CType_CommandBlock, + .Code = PIMA_OPERATION_OPENSESSION, + .TransactionID = 0x00000000, + .Params = {0x00000001}, }; /* Send the OPENSESSION block, open a session with an ID of 0x0001 */ SImage_SendBlockHeader(); /* Receive the response block from the device */ - if ((ErrorCode = SImage_RecieveBlockHeader()) != PIPE_RWSTREAM_ERROR_NoError) + if ((ErrorCode = SImage_RecieveBlockHeader()) != PIPE_RWSTREAM_NoError) { ShowCommandError(ErrorCode, false); break; @@ -320,18 +318,18 @@ TASK(USB_SImage_Host) PIMA_SendBlock = (PIMA_Container_t) { - DataLength: PIMA_COMMAND_SIZE(1), - Type: CType_CommandBlock, - Code: PIMA_OPERATION_CLOSESESSION, - TransactionID: 0x00000001, - Params: {0x00000001}, + .DataLength = PIMA_COMMAND_SIZE(1), + .Type = CType_CommandBlock, + .Code = PIMA_OPERATION_CLOSESESSION, + .TransactionID = 0x00000001, + .Params = {0x00000001}, }; /* Send the CLOSESESSION block, close the session with an ID of 0x0001 */ SImage_SendBlockHeader(); /* Receive the response block from the device */ - if ((ErrorCode = SImage_RecieveBlockHeader()) != PIPE_RWSTREAM_ERROR_NoError) + if ((ErrorCode = SImage_RecieveBlockHeader()) != PIPE_RWSTREAM_NoError) { ShowCommandError(ErrorCode, false); break; @@ -419,7 +417,7 @@ void UpdateStatus(uint8_t CurrentStatus) /** Displays a PIMA command error via the device's serial port. * * \param ErrorCode Error code of the function which failed to complete successfully - * \param ResponseErrorCode Indicates if the error is due to a command failed indication from the device, or a communication failure + * \param ResponseCodeError Indicates if the error is due to a command failed indication from the device, or a communication failure */ void ShowCommandError(uint8_t ErrorCode, bool ResponseCodeError) {