This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

HOW TO IMPLEMENT IN CALLBACK FOR CUSTOM CLASS

Using MDK-PRO, 4.74 (actually 5, with legacy pack). I am trying to make a custom generic BULK class. I followed the suggestions for implementing a custom OUT Pipe and it is working fine.
For my IN pipe I am having partial success.

Does anyone know what callback or function I need to overload so that I can get a callback or an event flag to tell my code to write a buffer with USBD_WriteEP()?

I have tried making a simple class overload task like:

__task void USBD_RTX_EndPoint1 (void){
    volatile U16 evt;

    for (;;) {
        os_evt_wait_or(0xFFFF, 0xFFFF);         /* Wait for an Event */
        evt = os_evt_get();                     /* Get Event Flags */

        CLS_BulkIn ();                      /* data to send to Host */
        evt &= ~USB_EVT_IN;
        os_evt_clr(USB_EVT_IN,USBD_RTX_EPTask[2]);
    }
}

void CLS_BulkIn()
{
 ..process data to make buffer to send...
 USBD_WriteEP(0x81,thebuffer,thecount);
}


but to no avail, this never gets an event. If I push data into the endpoint blindly, then the host will pick it up, however, I am trying to push data in response to an IN phase on the bus.
Hopefully,
-Steve

Parents
  • > If I push data into the endpoint blindly, then the host will pick it up

    You are on the right track, but don’t put it "blindly" (*1) ;-)

    USBD_WriteEP() should be called outside of USBD_RTX_EndPoint1(), at least for the first packet of sequential USBD_WriteEP() calls.

    Either on IN or OUT endpoint, the event (hardware interrupt) occurs just when a transaction completes.

    For IN endpoint,
    1) Your firmware fills the endpoint using USBD_WriteEP(), first.
    2) and wait for IN transaction, coming from host.
    3) At IN transaction, the endpoint sends the data to host
    4) When the transaction finishes, endpoint interrupt occurs.

    Therefore, the code flow is asymmetry, between IN and OUT.

    (*1) Once a packet is passed to the endpoint by USBD_WriteEP(), don’t put another packet, until USB_EVT_IN occurs.

    Tsuneo

Reply
  • > If I push data into the endpoint blindly, then the host will pick it up

    You are on the right track, but don’t put it "blindly" (*1) ;-)

    USBD_WriteEP() should be called outside of USBD_RTX_EndPoint1(), at least for the first packet of sequential USBD_WriteEP() calls.

    Either on IN or OUT endpoint, the event (hardware interrupt) occurs just when a transaction completes.

    For IN endpoint,
    1) Your firmware fills the endpoint using USBD_WriteEP(), first.
    2) and wait for IN transaction, coming from host.
    3) At IN transaction, the endpoint sends the data to host
    4) When the transaction finishes, endpoint interrupt occurs.

    Therefore, the code flow is asymmetry, between IN and OUT.

    (*1) Once a packet is passed to the endpoint by USBD_WriteEP(), don’t put another packet, until USB_EVT_IN occurs.

    Tsuneo

Children
No data