PSoC5 USBFS DTR detection using interrupt

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

cross mob
AnSa_1225656
Level 4
Level 4
50 replies posted 25 replies posted 10 replies posted

I am using interrupts in FreeRTOS to read data from USB and pass to UART (Using as software USB/UART bridge in one configuration).  I need to be able to control a DTR pin based on USB_GetLineControl(), but I am not sure how to detect a change in its status via an interrupt.  What interrupt will fire when this status changes?

0 Likes
1 Solution

This request goes through EP0, so yes, you could use the EP_0_ISR_ExitCallback(). But this function executes on any EP0 interrupt.

There is a more specific function that is executed when there is a class request (your case). Refer to the function USB_DispatchClassRqst in USB_cls.c.

In the end of the function, you can write code between this lines:

/* `#START USER_DEFINED_CLASS_CODE` Place your Class request here */

/* `#END` */

Or you can implement the USB_DispatchClassRqst_Callback() function and define the USBUART_DISPATCH_CLASS_RQST_CALLBACK. 

View solution in original post

4 Replies
Ekta_N
Moderator
Moderator
Moderator
750 replies posted First like given 250 solutions authored

Hello @AnSa_1225656 ,

Could you please confirm if you are asking where can the USB_GetLineControl() function be called to know if there is a change in status?
According to my understanding  you want to detect if a DTR signal is present using the function USB_GetLineControl() and based on the status control a DTR pin.

You can try calling this USB_GetLineControl() function in the USBUART_EP_0_ISR_ExitCallback() ISR.

You can refer to the Macro Callback section of the USBFS datasheet to find more details regarding how to use this ExitCallback function.

Kindly let me know if this is what you were looking for.

Thanks 
Ekta

0 Likes

Specifically, I want to know which interrupt(s) will fire when there is a change in DTR status.  Are you saying that the EP_0_ISR_ExitCallback() will fire whenever the line control register is changed?  If so, then I think you have answered my question.

-Andy

0 Likes

This request goes through EP0, so yes, you could use the EP_0_ISR_ExitCallback(). But this function executes on any EP0 interrupt.

There is a more specific function that is executed when there is a class request (your case). Refer to the function USB_DispatchClassRqst in USB_cls.c.

In the end of the function, you can write code between this lines:

/* `#START USER_DEFINED_CLASS_CODE` Place your Class request here */

/* `#END` */

Or you can implement the USB_DispatchClassRqst_Callback() function and define the USBUART_DISPATCH_CLASS_RQST_CALLBACK. 

OK, thank you both Ekta and RodolfoGL for your answers.  SOunds like I wnat the more specific USB_DispatchClassRqst  for my  purposes.

0 Likes