X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/071e02c6b6b4837fa9cf0b6d4c749994e02638d7..e61345f872fc7f1a8b95e53ee68b4dbdea0650db:/Demos/Host/LowLevel/PrinterHost/Lib/PrinterCommands.c diff --git a/Demos/Host/LowLevel/PrinterHost/Lib/PrinterCommands.c b/Demos/Host/LowLevel/PrinterHost/Lib/PrinterCommands.c index 5f3effa7b..0b75d7507 100644 --- a/Demos/Host/LowLevel/PrinterHost/Lib/PrinterCommands.c +++ b/Demos/Host/LowLevel/PrinterHost/Lib/PrinterCommands.c @@ -44,7 +44,8 @@ * * \return A value from the Pipe_Stream_RW_ErrorCodes_t enum */ -uint8_t Printer_SendData(const void* const PrinterCommands, const uint16_t CommandSize) +uint8_t Printer_SendData(const void* const PrinterCommands, + const uint16_t CommandSize) { uint8_t ErrorCode; @@ -55,11 +56,8 @@ uint8_t Printer_SendData(const void* const PrinterCommands, const uint16_t Comma return ErrorCode; Pipe_ClearOUT(); - while (!(Pipe_IsOUTReady())) - { - if (USB_HostState == HOST_STATE_Unattached) - return PIPE_RWSTREAM_DeviceDisconnected; - } + + Pipe_WaitUntilReady(); Pipe_Freeze(); @@ -74,7 +72,8 @@ uint8_t Printer_SendData(const void* const PrinterCommands, const uint16_t Comma * * \return A value from the USB_Host_SendControlErrorCodes_t enum */ -uint8_t Printer_GetDeviceID(char* DeviceIDString, const uint16_t BufferSize) +uint8_t Printer_GetDeviceID(char* DeviceIDString, + const uint16_t BufferSize) { uint8_t ErrorCode = HOST_SENDCONTROL_Successful; uint16_t DeviceIDStringLength = 0; @@ -84,7 +83,7 @@ uint8_t Printer_GetDeviceID(char* DeviceIDString, const uint16_t BufferSize) .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE), .bRequest = REQ_GetDeviceID, .wValue = 0, - .wIndex = 0, + .wIndex = PrinterInterfaceNumber, .wLength = sizeof(DeviceIDStringLength), }; @@ -128,11 +127,11 @@ uint8_t Printer_GetPortStatus(uint8_t* const PortStatus) { USB_ControlRequest = (USB_Request_Header_t) { - bmRequestType: (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE), - bRequest: REQ_GetPortStatus, - wValue: 0, - wIndex: 0, - wLength: sizeof(uint8_t), + .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE), + .bRequest = REQ_GetPortStatus, + .wValue = 0, + .wIndex = PrinterInterfaceNumber, + .wLength = sizeof(uint8_t), }; Pipe_SelectPipe(PIPE_CONTROLPIPE); @@ -152,7 +151,7 @@ uint8_t Printer_SoftReset(void) .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE), .bRequest = REQ_SoftReset, .wValue = 0, - .wIndex = 0, + .wIndex = PrinterInterfaceNumber, .wLength = 0, };