Sure, seems redundant. It might not have been redundant when it was written, that demo is..... very old. You can also register all sorts of filters and list the same callback, so you _may_ wish to be checking things there, perhaps consider it an example of how you can still access those fields? ;)
Writing nice doxygen for the usb sections would be awesome yes. Sincerely, Karl Palsson Mats Webjörn/WIKAB <kons...@webjorn.com> wrote: > Hi, > > I have a question on > libopencm3-examples\examples\stm32\f1\lisa-m-1\usb_hid\usbhid.c > . > > It defines > > static enum usbd_request_return_codes dfu_control_request( > usbd_device *dev, struct usb_setup_data *req, uint8_t **buf, > uint16_t *len, > void (**complete)(usbd_device *dev, struct usb_setup_data *req)) > { > (void)buf; > (void)len; > (void)dev; > > if ((req->bmRequestType != 0x21) || (req->bRequest != DFU_DETACH)) > return USBD_REQ_NOTSUPP; /* Only accept class request. */ > > *complete = dfu_detach_complete; > > return USBD_REQ_HANDLED; > } > > Which is registered in USBD using > > usbd_register_control_callback( > dev, > USB_REQ_TYPE_CLASS | USB_REQ_TYPE_INTERFACE, > USB_REQ_TYPE_TYPE | USB_REQ_TYPE_RECIPIENT, > dfu_control_request); > > My question is, why does dfu_control_request() check > bmRequestType with > > "if ((req->bmRequestType != 0x21)" ? > > > usb_control_request_dispatch() filters requests on the > registered request-type using > > "if ((req->bmRequestType & cb[i].type_mask) == cb[i].type)" > > So the check in dfu_control_request() is redundant and just > confusing for the reader. > > It would be nice if the callback typedefs in > libopencm3/include/libopencm3/usb/usbd.h Had the same kind of > doxygen declaration as the other functions. This would most > Likely eliminate these kind of misunderstandings of what the > presumptions of the callback was. > > Kind regards > > Mats Webjörn > > Tel +46 8 584 238 80 Webjörn IngenjörsKonsult AB Mobil +46 70 > 639 16 99 Solhemsbackarna 75A > SE-163 56 SPÅNGA > Sweden > > _______________________________________________ > libopencm3-devel mailing list > libopencm3-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/libopencm3-devel
OpenPGP-digital-signature.html
Description: OpenPGP Digital Signature
_______________________________________________ libopencm3-devel mailing list libopencm3-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libopencm3-devel