Example on how to use the USB control EndPoint EP0

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

cross mob
FrPo_1282226
Level 4
Level 4
25 replies posted 10 replies posted 10 questions asked

Hi there,

I need to be able to get control messages from the EP0.

I'm using a PSoC 5LP, and I can successfully read and Write USB messages on EP1 and EP2.

For compatibility reason I need to use the Endpoint 0 to configure the PSOC.

I have tried the following code, but is not working:

#define EP0 0

uint8_t  NewUSBMessage()

{

  uint8_t retVal;

  

    retVal =0;

    if (USB_bGetEPState(EP0)!= USB_OUT_BUFFER_EMPTY)

    {

    

        USB_ReadOutEP(EP0,Message,length);

        retVal = 1;

    

      

    }

  

    return retVal;

}

Can somebody help me please? send me some example link, etc.

Thanks,

Francesco

0 Likes
1 Solution
Len_CONSULTRON
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted

Francesco,

I'm not a USB configuration expert but here goes:

I'm assuming NewUSBMessage() is an ISR you want called when EP0 is activated.

You may need to make the following changes if you already haven't:

Rename the function NewUSBMessage() to <comp_name>_EP_0_ISR_ExitCallback()

Add the following lines into file cyapicallbacks.h:

#define <comp_name>_EP_0_ISR_EXIT_CALLBACK

void <comp_name>_EP_0_ISR_ExitCallback();

Note: <comp_name> needs to be substituted with the name of your USBFS component.

I've used USBFS and EP0 and these are the changes I had to add to get EP0 to be processes with my own code.

Len

Len
"Engineering is an Art. The Art of Compromise."

View solution in original post

3 Replies