cancel
Showing results for 
Search instead for 
Did you mean: 

how to config USB EP address instm32f407???

wangsenme
Associate II
Posted on July 04, 2016 at 05:02

In STM32F103,i use 

USB_EPnR to config endpoint address,

 

e.g. I can config endpoint1 with adress 0x0a,so  endpoint1 can communicate with host endpoint10。

 

But in STM32F407 i don‘t find where to config endpoint adress,only known in OTG_FS has 3 IN endpoint,i don’t how to set endpoint adress. 

 

if these 3 endpoint only support adress 1,2,3

?

Now,in my design, I need to communicate with endpoint8 of the host, how can i solve these problem?

4 REPLIES 4
Walid FTITI_O
Senior II
Posted on July 04, 2016 at 11:25

Hi a.wang,

Once the USB core is initialized, the upper layer can call the low level driver to open or close the active endpoint and start transferring data.

The following two APIs can be used:

HAL_StatusTypeDef HAL_PCD_EP_Open(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint16_t ep_mps, uint8_t ep_type)

HAL_StatusTypeDef HAL_PCD_EP_Close(PCD_HandleTypeDef *hpcd, uint8_t ep_addr)

ep_addr, ep_mps and ep_type are respectively the endpoint address, the maximum data transfer and transfer type.

You find further information in the ''STM32cube USB device library''

http://www.st.com/content/ccc/resource/technical/document/user_manual/cf/38/e5/b5/dd/1d/4c/09/DM00108129.pdf/files/DM00108129.pdf/jcr:content/translations/en.DM00108129.pdf

-Hannibal-

tsuneo
Senior
Posted on July 05, 2016 at 05:40

Hi wang,

USB ''Device'' engine on STM32F103 has capability to assign endpoint number exposed to the bus side for each endpoint. But on OTG_FS engine on F407, the endpoint number is fixed for each endpoint, 1, 2 or 3. The OTG_HS has also fixed EPs, 1,2,3,4,5.

> Now,in my design, I need to communicate with endpoint8 of the host, how can i solve these problem?

Revise the host code, so that it doesn't depend on a specific endpoint number.

Instead, search the target endpoint using endpoint attributes (such as bulk OUT / interrupt IN on a specific class/subclass interface)

''Fixed endpoint number'' is a bad coding practice on USB host implementation, because it should cause such trouble as you've experienced, limited endpoint assignment on new device.

Tsuneo

wangsenme
Associate II
Posted on July 05, 2016 at 11:43

thanks for telling me and ensuring that adress cant be revised.

But in my design,the host device is a 

Mature products,thus i cant

revise /(ã„’oã„’)/~~

In fact,my design is between host and divice . I must require data

when host communicating with device .

On f103 ,the adress can be configed but when stm32 use as device,this usb can't 

produce IN token interrupt,which can be solve on stm32f4.

So I will try stm32f4 agnin , and only use 123 enpoint to communicate.

If this cant 

success,i must to use extern USB chips.

After all I think , on stm32f4 , endpoint adress cant be configed, which does not 

according with the USB2.0  

specification.This can 

Compatible with other devices becuase usually we can't revise other device but our design.

wangsenme
Associate II
Posted on July 05, 2016 at 11:54

Thanks for your answer. I  have tried to  config endpoint adress

 using dcd_ep_open,but it doesn't work. I'm searching the problem now.

the addr parameter in this function revise DIPCTL reg,

txfifo num is written with addr ,but in the datasheet, it

 seems to say,txfifo num only support 1~3.(ã„’oã„’)