* how is it programmed in code?
* every status maps to what signaling?
UfnMdd_Start() @publiccommonoakdriversusbfncontrollermddUfnmdd.cpp ->
ZyUSBOTG_ULPI::NewStateAction() @platformzylonite_mhlvsrdriverotg_upliUsbotg_lupi.cpp
*what's Device A&B? -> A = Host, need to offer Vbus , B = peripheral
No device attached: D+ and D- float to 0V if not driven
FS device attached: D+ floats to 4.54V and D- floats to 0V if not driven
LS device attached: D+ floats to 0V and D- floats to 4.54V if not driven
*pull-down resistance
when A/B-device is idle or acting as Host, D+ -> pull low (R 14.25k -24.8k) D- -> pull low (R 14.25k -24.8k)
when A/B-device is acting as a peripheral, D+ disable pull-down(floating) and D-> pull-down, A prevent B-device's D- floating if the B-device becomes unplugged and B is the same that of A-device.
During the interval of packet transmission, A/B-device is allowed to disable D+ and D- pull-down resistor
*pull-up resistance
A/B-device is operating as Peripheral, D+ -> pull-up
During the interval of packet transmission, A/B-device is allowed to disable D+ pull-up resistor
*if one side is not OTG device, how does the protocol go?
J state -> idle state -> D+>D-(differential 1) for FS, D+<D-(differential 0) for LSK state -> D+<D-(differential 0) for FS, D+>D-(differential 1) for LS
*What's Host Negotiation protocol(HNP)?
- A-device sends a SetFeature(b_hnp_enable) command.
- A-device suspend bus.
- B-device signals a disconnect to the A-device.(if B-device want to use bus)
- A-device interrupts this disconnect.(if A-device enable to switch)
- A-device turns on pull-up resistor on D+.
A) A-device finishes using bus and stops all bus activity, (i.e. suspends the bus).
A) A-device 用完bus 然後停止所有的bus 的運作,(例如suspends the bus)
B) B-device detects that bus is idle for more than TA_AIDL_BDIS min and begins HNP by turning off pull-up on D+. This allows the bus to discharge to the SE0 state. If the bus was operating in HS mode, the B-device will first enter the full-speed mode and turn on its D+ pull-up resistor for at least TB_FS_BDIS min before turning off its pull up to start the HNP sequence.
B) B-device 偵測到bus idle 超過 TA-AIDL_BDIS min 之後開始 HNP , 透過關掉 D+的pull-up。 這麼做可以讓bus 進入 SE0 state(D+ and D- go low). 如果 bus 正在運作在 HS mode, B-device 會先進入 FS mode 並開啟 D+ pull-up 阻抗至少 TB_FS_BDIS min ,在關掉pull-up 阻抗去開始NHP程序之前.
Note: After B-device enters the FS mode and turns on its pull-up resistor; it waits to see if the data line goes high. If the data line does not go high within TWTRSTHS (from Table 7-14 in USB 2.0 specification [USB2.0]), then the B-device shall start its HS chirp. Otherwise, if the D+ line does go high for at least TB_FS_BDIS min, then the B-device may start HNP.
注意: 在B-device 進入 FS mode 並開啟 pull-up 阻抗之後; 它會等並看看是否資料線是hi. 如果資料線沒有go high 至少 TWTRSTHS(在USB 2.0 的Table 7-14有提到), B-device 可能會開始它的 HS chirp。否則,如果D+ line 有go high 至少 TB_FS_BDIS min, 則B-device 開始 NHP.
C) The A-device detects the SE0 on the bus and recognizes this as a request from the B-device to become Host. The A-device responds by turning on its D+ pull-up within TA_BDIS_ACON max of first detecting the SE0 on the bus.
C) A-device 偵測到 SE0 並了解這個是 B-device 要變成 Host 的要求。A-device 回應,透過開啟 D+ pull-up 要在第一次偵測到 SE0 的 TA_BDIS_ACON 的最大值之間。
D) After waiting long enough to insure that the D+ line cannot be high due to the residual effect of the B-device pull-up, (see Section 5.1.9), the B-device sees that the D+ line is high and D- line is low, (i.e. J state). This indicates that the A-device has recognized the HNP request from the B-device. At this point, the B-device becomes Host and asserts bus reset to start using the bus. The B-device must assert the bus reset (SE0) within TB_ACON_BSE0 max of the time that the A-device turns on its pull-up.
D) 在等待一段長時間來確定 D+ 線不會是 hi 之後(由於B-device pull-up 的殘餘的影響 Section 5.1.9) , B-device 會看到D+>D-(例如 J State)。這說明了A-device 已經辦識到 HNP 的要求來自B-device。在這個時候, B-device 變成 Host 並reset bus 來開始使用bus. B-device 必須告知 bus reset (SE0) 在 TB_ACON_BES0的最大值之間, 這個時間是A-device 開啟它的pull-up 的時候。
E) When the B-device completes using the bus, it stops all bus activity. (Optionally, the B-device may turn on its D+ pull-up when a FS idle condition is detected on the bus.)
E) 當B-device 用完bus 時, 它停止所有bus 上的運作(B-device 可能會開啟 D+ pull-up 當偵測到 FS idle 在bus 上)
F) A-device detects lack of bus activity for more than TA_BIDL_ADIS min and turns off its D+ pull-up. Alternatively, if the A-device has no further need to communicate with the B-device, the A-device may turn off VBUS and end the session.
F) A-device 偵測到busy 沒有活動超過 TA_BIDL_ADIS min 然後就關掉 D+ pull-up. 如果A-device 沒有更進一步的需要來跟B-device 溝通的話,A-device 關掉Vbus 然後結束 session.
G) B-device turns on its pull-up.
G) B-device 開啟 pull-up.
H) After waiting long enough to insure that the D+ line cannot be high due to the residual effect of the A-device pull-up, (see Section 5.1.9), the A-device sees that the D+ line is high (and D- line is low)indicating that the B-device is signaling a connect and is ready to respond as a Peripheral. At this point, the A-device becomes Host and asserts bus reset to start using the bus.
H) 在等待一段長時間來確定 D+ 線不會是 hi 之後(由於A-device pull-up 的殘餘的影響 Section 5.1.9) , A-device 會看到D+ -> hi, (D- -> low)。這說明了B-device 正在連接並且準備好回應如同一個 Peripheral. 在這個時候, A-device 變成 Host 並reset bus 來開始使用bus.