USB host mode in Android device supporting OTG

我只是一个虾纸丫 提交于 2021-02-08 03:36:06

问题


I'd like to know in which mode a USB-OTG-supporting Android device is by default, - in the USB host mode or USB slave mode ?
I guess, if the device is in slave mode, then there's no point of using API described on link below ? https://developer.android.com/guide/topics/connectivity/usb/host.html
Is there a way to programmatically switch from host to slave mode and vice versa ?

As you know, a USB OTG (On the go) device automatically switches to host or slave mode, depending on which end of an OTG-specific cable has been inserted into device

And the second question is, in case if a device has necessary OTG ports, but the kernel does not support OTG yet, which parts of the kernel should be modified in order to be able to set host-slave mode, based on cable end detection ? (no need to implement HNP)


回答1:


There is no "default" mode in USB OTG. OTG controller detects the state the USB's fifth pin(ID pin). If the ID-pin is grounded or floating, the connected device is a Host or device.

USB 2.0 spec introduced 3 new protocols, ADP, SRP, HNP. Pls reference HNP for "a way to programmatically switch from host to slave mode and vice versa".

As your second question, I think detect the ID-pin is a function of OTG controller.



来源:https://stackoverflow.com/questions/12887672/usb-host-mode-in-android-device-supporting-otg

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!