cancel
Showing results for 
Search instead for 
Did you mean: 

STM32_USB-Host-Device_Lib - receiving

turboscrew
Senior III
Posted on January 14, 2014 at 14:52

How do I receive USB IN data with a host using the library mentioned in the title?

Do I have to poll by trying to receive from different IN EPs, or is there some interrupt based state change to indicate whether receive needs to be called or not?

Or do I just have to poll URB_State or HC_Status for that EP?

Especially I'm trying to receive device notificatons via interrupt IN ep, getting any IN data is important though.

7 REPLIES 7
tsuneo
Senior
Posted on January 14, 2014 at 15:39

As of the interrupt IN endpoint, refer to the code in USBH_HID_Handle() (usbh_hid_core.c)

Tsuneo

turboscrew
Senior III
Posted on January 14, 2014 at 16:56

The site seems to have problems. Every now and then posting causes some error and an advice is given to find out about the problem using sharepoint tools. (?)

Usually the posting ends up on the site, but this time it didn't.

So:

It looks like the HID polls the URB_State.

How about control/bulk IN (URB state doesn't seem to be set for them) in general case?

Should HC_Status be used (after interrupt transfer poll) for control/bulk transfers?

MSC host is a bit complicated example (USBH_MSC_Handle + ... + USBH_MSC_HandleBOTXfer).

Does HID read double frames, or what's the ''start_toggle''?

The state change seems to be:

HID_POLL (polling) --> HID_GET_DATA

HID_GET_DATA (first frame)  --> HID_POLL

HID_POLL (second frame) --> HID_POLL

Or did I misunderstand something?

turboscrew
Senior III
Posted on January 15, 2014 at 20:01

When can a new control transfer be started?

Any time, or should URB_Status have a certain value?

How about receiving? When the receiving function returns USBH_OK, is the data ready to be handled, or is it just that the token has been sent? Should one poll for URB_Status to turn to ''done''?

Are there any delays needed?

turboscrew
Senior III
Posted on January 16, 2014 at 09:10

Ah, now I got the HID example:

HID_GET_DATA is the polling and the start_toggle tells the next state

HID_POLL if the URB_DONE is from old data or new data.

(It could hane named ''new_data'' as well.)

The state machine loops mostly in HID_POLL state, and when the time comes, it ''drops by'' the HID_GET_DATA state to poll for new data, and when the request sending is finished, it returns to the HID_POLL state.

Stating it here for others, that might find the explanation useful.

turboscrew
Senior III
Posted on January 16, 2014 at 18:56

Got the RNDIS control message transfer to work. Just bulk I/O missing, but alas, I run out of time. Other people will finish it. Time flies when you're having fun.

[DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/STM32%20USB%20On-The-Go%20Host%20and%20Device%20Library%20structure&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=283]https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=%2fpublic%2fSTe2ecommunities%2fmcu%2fLists%2fcortex_mx_stm32%2fSTM32%20USB%20On-The-Go%20Host%20and%20Device%20Library%20structure&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=283

Fortunately I know enough to help and to guide the guys in, and I have a goot understanding how the bulk I/O should be done.

It was quite an intensive course in USB programming, but I got A LOT!

Once again: loads and loads of thanks to Tsuneo for being so devoted teacher here.

Wood.Andy
Associate III
Posted on February 23, 2015 at 14:35

Hi

RNDIS looks like something I have to have a look at, do you have anything you are willing to share?

Thanks

Andy.

turboscrew
Senior III
Posted on March 18, 2015 at 00:11

Better late than never (I hope).

I can't share the code for two reasons - I'm laid off indefinitely and the code is owned by our company's client.

You could get a pretty good idea if you read my postings and answers to them.

My advice is: figure out the essential functions (the postings can be helpful), and the rest will come together by following the code.

I recall the good starting points were enumeration (control part) and the data polling functions (tx and rx). The control part and the data part are pretty independent of each other.

(At least that's how I remember it.)