1 Reply Latest reply on Oct 23, 2019 4:31 AM by LeEs_793571

    USBFS Finding wMaxPacketSize?




      I'm working on a USB device for a specific class and I need to send a zero length packet if my last packet was a full packet (which seems to be a fairly common requirement.)


      Therefore I need to know that the max packet size is ... obviously I know because I configured it on the component, however it seems crazy to duplicate this in the code and run the risk of one changing without the other. Is there some way of getting this programmatically?


      (I can see it deep in the descriptor defines, but I cant see a simple and foolproof way of getting at it.)


      Also, as a side question ... am I right in assuming that for bulk endpoints LoadInEP() only supports transfers up to the wMaxPacketSize?


      Many thanks,



        • 1. Re: USBFS Finding wMaxPacketSize?

          Answering my own question...


          There is a structure that has the endpoint configuration and the size of the buffer is part of it. I am presuming that this only works for manual allocations where the endpoint buffer will be the same size as the max packet.




          For my second question it's a bit of a nasty answer.


          USBFS_LoadInEp() appears to allow a size of anything up to whatever space exists from the start point of your endpoint buffer, through to the end of the 512 byte total space. It will silently reduce the length down to this size and not tell you ... and if you want to take advantage of this then you will have to calculate the size yourself.


          I've only just started experimenting with USB on the PSoC, and maybe it's because I'm not too familiar with the principles, but the API seems pretty awful compared with many of the other components.