PSoC5LP:How to erase the data set in the USBFS in-endpoint ?

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

cross mob
TaMa_4718096
Level 2
Level 2
10 replies posted First like given 5 questions asked

Hello,

I use LoadInEP() to set the send data to the in-endpoint as shown below.

     if(USBFS_GetEPState(IN_EP) == USBFS_IN_BUFFER_EMPTY)
     {
          USBFS_LoadInEP(IN_EP, tramsmit_data, 64);
     }

I want to set another data, but I can't set it unless the host reads it.

If the host doesn't read for a period of time, I want to erase the previous data, what should I do ?

0 Likes
1 Solution
Ekta_N
Moderator
Moderator
Moderator
750 replies posted First like given 250 solutions authored

Hi,

Yes,  you need to call the USBFS_ConfigReg() function before initializing the particular endpoint.

What I meant was you could implement you own function in which you could first call the USBFS_ConfigReg() function, followed by initializing the particular endpoint. This would prevent you from initializing other endpoints and clearing their data as well.

In your case there if there is no issue with changing the endpoint state of other endpoints you can go ahead and use the USBFS_RestoreConfig function directly.

Best Regards

Ekta

View solution in original post

0 Likes
5 Replies
TaMa_4718096
Level 2
Level 2
10 replies posted First like given 5 questions asked

Hello,

I have confirmed that the previous data can be erased by restoring using the following function before starting the next data transmission.

     USBFS_RestoreConfig();

Is there anything wrong with this usage ?

0 Likes
Ekta_N
Moderator
Moderator
Moderator
750 replies posted First like given 250 solutions authored

Hi,

Using the USBFS_RestoreConfig function will affect the state of all endpoints.

The USBFS_RestoreConfig function in turn calls the USBFS_EpStateInit(), which is implemented as:

for (i = USBFS_EP1; i < USBFS_MAX_EP; i++)

{

        if (0u != (USBFS_EP.addr & USBFS_DIR_IN))

    {

           /* IN Endpoint */

      USBFS_EP.apiEpState = USBFS_EVENT_PENDING;

    }

      else

    {

           /* OUT Endpoint */

      USBFS_EP.apiEpState = USBFS_NO_EVENT_PENDING;

    }

}

Instead of initializing all the endpoints to clear the data you can simply implement something like:

USBFS_EP.apiEpState = USBFS_EVENT_PENDING;

where x the EP number of the IN endpoint that you want to clear.

Best Regards

Ekta

0 Likes

Hi, Ekta,

Thank you for your answer.

It was not possible to erase the already set data with only the following functions.
     USBFS_EP.apiEpState = USBFS_EVENT_PENDING;

I think the following functions that USBFS_RestoreConfig() function calls are important.
     USBFS_ConfigReg();

0 Likes
Ekta_N
Moderator
Moderator
Moderator
750 replies posted First like given 250 solutions authored

Hi,

Yes,  you need to call the USBFS_ConfigReg() function before initializing the particular endpoint.

What I meant was you could implement you own function in which you could first call the USBFS_ConfigReg() function, followed by initializing the particular endpoint. This would prevent you from initializing other endpoints and clearing their data as well.

In your case there if there is no issue with changing the endpoint state of other endpoints you can go ahead and use the USBFS_RestoreConfig function directly.

Best Regards

Ekta

0 Likes

Hi, Ekta,

Thank you for your cooporation.

If it doesn't affect other endpoints, I understand that I can use the USBFS_RestoreConfig function.

I decided to use USBFS_RestoreConfig function.

0 Likes