AnsweredAssumed Answered

USB Host Rec Data Callback

Question asked by Jeff King on Apr 22, 2015
Latest reply on Apr 29, 2015 by Kan_Li



I'm using the K64F platform with KDS 2.0 w/ KSDK 1.1 along with the component fsl_usb_framework.


Does anyone know why my usb_host_recv_data() callback that I pass in only gets hit sometimes?  And only the first call I make to it?


Here's a snippet (for clarity sake, I removed my error handling):


// open my pipe (INTERRUPT PIPE RECV)

usb_host_open_pipe(usbFmw1_Handler, &pipeIn, &pipe_init)


// get tr structure and pass in my callback (which gets setup in my tr structure)

tr_struct_t* tr_ptr2;

usb_host_get_tr(usbFmw1_Handler, read_done, NULL, &tr_ptr2)


// setup my receive buffer and size

tr_ptr2->rx_buffer = readbuf;

tr_ptr2->rx_length = 1024;


// call recv

usb_host_recv_data(usbFmw1_Handler, pipeIn, tr_ptr2


typically if I have a breakpoint set at usb_host_recv_data; my callback for read_done will be called with a status of 0x0.  All good.  If I don't have a breakpoint, my callback never gets hit.  If I try and call these functions again after the callback then I never get a second hit into read_done callback.


Any idea why my callback is sometimes working the first time around and never called the second time?


I'm thinking I have to loop constantly waiting for data (I have a USB device with buttons).  It'd be great if it was a blocking call and just sat till data came across the line.