Hi
while implementing Media Transfer Protocol MTP I wanted to know how many bytes were transmitted by the host on EPOUT.
I had to do a bit of research and trial/error - I'd like to share my results so others might save time.
(and the Nordic team can correct me if I'm wrong)
there's a function
size_t nrfx_usbd_epout_size_get ( nrfx_usbd_ep_t ep )
which looks exactly like what I was looking for.
BUT:
if I'm doing an EPOUT transfer with a buffer of 256 bytes (0x0100) and the host sends 82 bytes (0x0052) then this function will return 0x0012 which is just the remaining size of the last 64-byte transfer.
Since the event handler is called for APP_USBD_EVT_DRV_EPTRANSFER when a full buffer is received (0x0100) or the transfer terminated (0x0052) the result value of 0x0012 does not help.
I find this function is used in modules/nrfx/drivers/src/nrfx_usbd.c and I guess it is intended for low level use only.
what works:
nrfx_usbd_ep_status_get( nrfx_usbd_ep_t ep, size_t * p_size )
this gives the expected size 0x0052
you can find code which is using nrf_drv_usbd_ep_status_get() in
<SDK>/components/libraries/usbd/class/msc/app_usbd_msc.c
best regards
Peter