From: Nuno S. <ns...@ed...> - 2009-07-07 17:18:35
|
Hi Tim, I have this working already. I couldn't really found the problem. I started to use some leds to see the value of the bmRequestType and it was delivering the right value sent by the host. Then i started to make the inverse process, and putting it right in place. I have this fully working now. Just for the records: EVENT_HANDLER(USB_UnhandledControlPacket) { // Handle specific control requests switch (bRequest) { case REQ_MY_REQUEST: if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_VENDOR | REQREC_DEVICE) ) { // do stuff // Acknowedge the SETUP packet, ready for data transfer Endpoint_ClearSetupReceived(); // Send an empty packet to acknowedge the command Endpoint_ClearSetupIN(); } break; } In the libusb side: int sendRequest(uint8_t request) { int r; r = libusb_control_transfer(handle, CTR_OUT, request, 0, 0, NULL, 0, 1000); if (r < 0) { fprintf(stderr, "set mode error %d\n", r); return r; } return 0; } Where #define CTR_OUT 0x40 #define REQ_MY_REQUEST 0x00 Thank you very much, With my best regards, Nuno Tim Roberts wrote: > Nuno Santos wrote: > >> I'm claiming interface before setting mode: >> >> > > That shouldn't be necessary, strictly speaking, although it won't hurt, > either. > > >> This is my device side control packets handling (LUFA syntax): >> >> case 0x12: >> if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_VENDOR | >> REQREC_DEVICE)) >> { >> Endpoint_ClearSetupReceived(); >> >> PORTD ^=0xff; >> >> /* Send the flag to the host */ >> Endpoint_ClearSetupOUT(); >> } >> >> break; >> >> > > There are apparently several different versions of the LUFA library, so > I can't actually verify whether this is the intended sequence or not. > Quite a number of the existing samples use Endpoint_ClearSetupIN(); > for a host-to-device request. This is backwards from intuition, because > in USB the terms "IN" and "OUT" are almost exclusively used from the > point of view of the host. > > The LUFA documentation from June 2009 only shows Endpoint_ClearSETUP, > with no distinction between IN and OUT. > > |