USBFS Finding wMaxPacketSize?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
LeEs_793571
Level 2
Level 2
5 replies posted 5 questions asked 5 sign-ins

Hi,

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,

Lee.

0 Likes
1 Solution
LeEs_793571
Level 2
Level 2
5 replies posted 5 questions asked 5 sign-ins

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.

USBFS_EP[<endpoint>].bufferSize

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.

Lee.

View solution in original post

0 Likes
1 Reply
LeEs_793571
Level 2
Level 2
5 replies posted 5 questions asked 5 sign-ins

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.

USBFS_EP[<endpoint>].bufferSize

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.

Lee.

0 Likes