/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / USB TX Interrupt / status flag?

Username:     
Password:     
             

Forum

# 1   2009-06-04 08:20:41 USB TX Interrupt / status flag?

nacnud
New member
Registered: 2008-07-11
Posts: 2

USB TX Interrupt / status flag?

Folks,

I'm wondering if the hardware can be convinced to give me a call back when it's finished sending data to the host over a USB connection? I have it sending data just now:

        UserToPMABufferCopy(text, ENDP1_TXADDR, intLen);
        SetEPTxCount(ENDP1, intLen);
        SetEPTxValid(ENDP1);   

That's pretty much example code to fire a buffer back over the USB. However, I'd like to know when that transfer finished via a status flag or interrupt. Am I missing something obvious?


Thanks for your input.

Dunk

$1
If you're using the STM Flib then you can fiddle with Virtual_Com_Port_Data_Size smile


PS. I wrote http://wiki.fosstronics.com/exti_notes in case anyone is interested in that nonsense. I'm sure it's FAR from complete:)

Offline

 

# 2   2009-06-10 19:23:27 USB TX Interrupt / status flag?

bbczeuz
New member
Registered: 2009-06-10
Posts: 1

Re: USB TX Interrupt / status flag?

Above code is a big hack (it's from the examples, i know). There's no check to make sure no data gets overwritten.
I'm also searching for a reliable method (besides double buffering of course)
- _GetEPTxCount should be zero before you put new data into the buffer (?)
- _GetEPTxStatus should not be EP_TX_VALID anymore when the buffer's empty

I'm still working on a solution. None of the above has helped so far.

Offline

 

# 3   2010-04-06 22:02:48 USB TX Interrupt / status flag?

iX3
Member
Registered: 2010-04-06
Posts: 11

Re: USB TX Interrupt / status flag?

Has anyone found a good solution for this? I was trying to use GetEPTxCount() but the results don't ever seem to change. Maybe I am misunderstanding something? In the mean time I have a soft-delay (not blocking critical code, but stalling transmission of next 64 bytes). Since this is a virtual COM port application I can get away with this, but I don't like it.

Offline

 

# 4   2010-04-07 07:09:15 USB TX Interrupt / status flag?

yrt
Administrator
From: Grenoble-France
Registered: 2008-06-11
Posts: 520
Website

Re: USB TX Interrupt / status flag?

The "CTR_TX" bit of the USB endpoint register indicates when the transmit is done.
But all is managed under interrupt by the ST library, that calls the appropriate callback functions, depending on the endpoint and the interrupt.
In your case, when a transmit is correctly finished, the EPx_IN_Callback is called. I think you can use it to manage the transmission and to ensure that there is no overwritten data.

Offline

 

# 5   2010-04-07 14:41:19 USB TX Interrupt / status flag?

iX3
Member
Registered: 2010-04-06
Posts: 11

Re: USB TX Interrupt / status flag?

Thank you; that is exactly what I wanted to know. Adding code to update the buffer status variable in that callback function solved the problem.

In fact, now that you mention this, I did see a counter variable being cleared in the EP1_IN_Callback function of the virtual com port (VCP) example, but I didn't realize its significance because I was unfamiliar with the USB protocol (e.g. "IN" meaning data is being sent into the host and out from the device). It is much clearer now; thanks again.

Offline

 

Board footer