- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Solved! Go to Solution.
- Labels:
-
PSoC 5LP
- Tags:
- usb
- usb endpoint ep0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Len!
it worked!
I'm writing the solution in case other people need it.
In order to read the messages from EP0 I have added
#define USB_EP_0_ISR_EXIT_CALLBACK
void USB_EP_0_ISR_ExitCallback();
in cyapicallback.h
and I wrote this function:
void USB_EP_0_ISR_ExitCallback(){
int length = USB_currentTD.count;
if (length == 😎
for (int i = 0; i< length; i++)
{
Message = USB_currentTD.pData;
}
}
which seems working.
Now I'm having the opposite problem I can't sens (anymore) data to the IN EP1).
the PSoC
// wait until our IN Endpoint is empty
while(USB_GetEPState(UNDPOINTIN) != USB_IN_BUFFER_EMPTY);
Do you know what else could be wrong now?
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Francesco,
For the functions like USBFS_ReadOutEP(), the valid value of endpoint number ranges from 1 to 8. You cannot give 0 for the endpoint number parameter in it.
As already mentioned by Len you can use the USBFS_EP_0_ISR_ExitCallback() and USBFS_EP_0_ISR_EntryCallback() ISR's located in the USBFS_dvrc.c . These ISR's are triggered to handle control transfers directed to endpoint.
To use these ISRs you need to define USBFS_EP_0_ISR_ENTRY_CALLBACK (or USBFS_EP_0_ISR_EXIT_CALLBACK) in the cyapicallbacks.h as shown in the image below:
Then define the USBFS_EP_0_ISR_EntryCallback() function in the main.c to perform the desired function.
Regards
Ekta