USB OTG state Diagram

USB <wbr>OTG <wbr>state <wbr>Diagram

The A-device state diagram shown in Figure 6-2 consists of the following eight states:

• a_idle
• a_wait_vrise
• a_wait_bcon
• a_host
• a_suspend
• a_peripheral
• a_wait_vfall
• a_vbus_err
There is a transition to the On-The-Go B-device start state (b_idle) that occurs if the cable is disconnected. When the A-Device is in any state except the a_idle state, the A-Device transitions to the a_wait_vfall state before transitioning to the a_idle state and then to the b_idle state.
6.8.1.1 a_idle
This is the start state for A-devices.
The A-device transitions to the a_wait_vrise state:
• if the A-device application is not wanting to drop the bus (a_bus_drop = FALSE), and either of the following are true:
• the A-device Application is requesting the bus (a_bus_req = TRUE), or
• SRP is detected on the bus (a_srp_det = TRUE).
As indicated in Section 5.3.12, some OTG devices may be configured such that a change in ID from TRUE to FALSE cause a_bus_req to be asserted.
6.8.1.2 a_wait_vrise
In this state, the A-device waits for the voltage on VBUS to rise above the A-Device VBUS Valid threshold (a_vbus_vld = TRUE). Upon entering this state, the A-device starts a timer: a_wait_vrise_tmr.
The A-device transitions to the a_wait_bcon state:
• if the voltage on VBUS has risen above the A-device VBUS Valid threshold (a_vbus_vld = TRUE), or
• if the a_wait_vrise_tmr expires.
6.8.1.3 a_wait_bcon
In this state, the A-device waits for the B-device to signal a connection. Upon entering this state, the A-device starts a timer: a_wait_bcon_tmr.
The A-device transitions to the a_wait_vfall state:
• if the cable is removed (id = TRUE), or
• if the A-device Application wants to drop the bus (a_bus_drop = TRUE), or
• if the a_wait_bcon_tmr times out (a_wait_bcon_tmout = TRUE).
If VBUS drops below the A-device VBUS Valid threshold (a_vbus_vld = FALSE), then the A-device transitions to the a_vbus_err state.
If the A-device detects the B-device signaling a connection (b_conn = TRUE), then the A-device shall end the session or transition to the a_host state and generate a bus reset within TA_BCON_ARST. See Section 6.6.1.12 for information on b_conn.
Note: a device may set its a_wait_bcon_tmr to an arbitrarily large value and wait an indefinitely long period of time for the B-device to connect.
6.8.1.4 a_host
Upon entering this state, the A-device resets the bus to prepare the B-device for packet traffic.
If a_bus_req = TRUE, then the A-device application wants to communicate with the B-device, and the A-device performs the following actions:
• A-device enumerates B-device
• if A-device supports B-device (i.e. B-device is on Targeted Peripheral List), then A-device sets up communication with B-device
• else if A-device does not support B-device then A-device outputs message to user indicating that B-device is not supported
• A-device sets a_bus_req = FALSE
Before ending the session, the A-device must allow an On-The-Go B-device the opportunity to take control of the bus. To do this, the A-device sends a SetFeature(b_hnp_enable) command. The A-device may send the SetFeature(b_hnp_enable) command to any B-device but is only required to send the command if the B-device is HNP capable (indicated in the OTG Descriptor). If the B-device responds to the SetFeature(B_hnp_enable) with a STALL, then the B-device is not HNP capable. ”If the SetFeature(b_hnp_enable) command is sent and accepted during the session, then the A-device shall exit to the a_suspend state and wait for the B-device to start a session (See Section 6.5.2)” The A-device is allowed to transition to the a_suspend state without setting b_hnp_enable, if it does not want the B-device to become Host but wants to continue to power the bus (possibly in expectation of imminent user input). If it does suspend the bus without enabling HNP, then it must at some later time return to this state and enable HNP if the B-device is On-The-Go.
The On-The-Go A-device is required to perform HNP within TA_SRP_RSPNS max if it enumerates the B-device and discovers that the test device (defined in section 6.6.6) is attached. The On-The-Go A-device is not required to display an unsupported device message when attached to the test device. If the On-The-Go A-device does display an unsupported device message, the message shall not delay HNP. When connected to a test device, an A-device is not allowed to drive a resume signal longer than 30 seconds.
If an A-device has already granted the role of host to the test device once during a session, then the A-device is not required to grant the role of host to test device again during the same session.
Under the following conditions, the A-device transitions from the a_host state to the a_wait_bcon state:
• if the cable is removed (id = TRUE), or
• if the A-device wishes to stop powering VBUS (a_bus_drop = TRUE), or
• if the B-device disconnects (b_conn = FALSE).
If VBUS is or drops below the VBUS Valid value (a_vbus_vld = FALSE), then the A-device transitions to the a_vbus_err state.
6.8.1.5 a_suspend
Upon entering the a_suspend state, the A-device starts the a_aidl_bdis_tmr. This timer can be set to an arbitrarily long time, but must be longer than TA_AIDL_BDIS min.
On-The-Go Supplement to the USB 2.0 Specification December 5, 2006
Revision 1.3
41
The A-device transitions to the a_wait_vfall state:
• if the a_aidl_bdis_tmr times out (a_aidl_bdis_tmout = TRUE), or
• if the A-device wishes to stop powering VBUS (a_bus_drop = TRUE) , or
• if the the cable is removed (id = TRUE).
If the B-device signals a disconnect (b_conn = FALSE), and the A-device was successful in setting b_hnp_enable (a_set_b_hnp_en = TRUE), then the A-device transitions to the a_peripheral state.
The A-device transitions to the a_host state if either a_bus_req is asserted, or if the B-device signals a resume by putting a K state on the bus, even if the remote_wakeup feature has not been enabled. If a_bus_req is asserted, then the A-device can either do a resume by putting a K state on the bus, or it can do a bus reset by outputting SE0 for longer than TB_ASE0_BRST max. The On-The-Go A-device is not allowed to resume unless the attached device is supported, or until TA_AIDL_BDIS max time has elapsed.
If the B-device signals a disconnect (b_conn = FALSE), and the A-device did not set b_hnp_enable (a_set_b_hnp_en = FALSE), then the A-device transitions to the a_wait_bcon state.
If VBUS is or drops below the A-device VBUS Valid value (a_vbus_vld = FALSE), then the A-device transitions to the a_vbus_err state.
6.8.1.6 a_peripheral
In this state, the A-device signals a connection to the B-device (loc conn = TRUE) and responds to requests from the On-The-Go B-device. If the A-device is capable of HS operation, then it shall begin the high-speed detection handshake whenever a bus reset is detected.
The A-device transitions from the a_peripheral state to the a_wait_vfall state:
• if the cable is removed (id = TRUE), or
• if the A-device is no longer capable of powering VBUS (a_bus_drop = TRUE).
If the A-device detects more than TA_BIDL_ADIS min of continuous idle (i.e. J_state for full-speed or SE0 for high-speed), on the bus, then the A-device may transition to the a_wait_bcon state. If no activity is detected after TA_BIDL_ADIS max the A-device must transition back to the a_wait_bcon state.
If VBUS is or drops below the A-device VBUS Valid threshold (a_vbus_vld = FALSE), then the A-device transitions to the a_vbus_err state.
This is the only state in which the A-device will signal a connection to the B-device.
6.8.1.7 a_wait_vfall
In this state, the A-device waits for the voltage on VBUS to drop below the A-device Session Valid threshold (a_sess_vld = FALSE) and for the B-device to drop D+/D- to indicate that it has detected the end of the session. Once both of these conditions are met, then the A-device transitions to the a_idle state. If the A-device is not On-The-Go and does not respond to the VBUS pulsing SRP, then the A-device transitions to a_idle when the bus enters the SE0 state and does not wait for VBUS to fall below the VA_SESS_VLD, threshold.
6.8.1.8 a_vbus_err
In this state, the A-device waits for recovery of the overcurrent condition that caused it to enter this state. Upon assertion of a_clr_err (nominally by system software), the A-device transitions to the a_wait_vfall state.

USB <wbr>OTG <wbr>state <wbr>Diagram

The On-The-Go B-device state diagram consists of five distinct states:
• b_idle
• b_srp_init
• b_peripheral
• b_wait_acon
• b_host
6.8.2.1 b_idle
In this state, the On-The-Go B-device waits for a session to start by monitoring if VBUS rises above the B-Device Session Valid threshold (b_sess_vld = TRUE). If VBUS rises above this threshold, the On-The-Go B-device enters the b_peripheral state and signals a connect (loc_conn = TRUE).
The B-device transitions from the b_idle to the b_srp_init state:
• if the Application indicates that it wants to start a session (b_bus_req = TRUE), and
• if VBUS is below the B-device Session End threshold (b_sess_end = TRUE), and
• if the bus has been in the SE0 state for at least TB_SE0_SRP min.
If the Micro-A plug is inserted (id = FALSE), then the On-The-Go B-device transitions to the a_idle state and becomes an A-device.
6.8.2.2 b_srp_init
Upon entering this state, the On-The-Go B-device attempts to initiate a session via SRP. Upon completion, the On-The-Go B-device returns to the b_idle state, nominally to wait for the A-device to drive VBUS above the B-Device Session Valid threshold (b_sess_vld = TRUE). Since the B-Device cannot distinguish between the A-device driving Vbus high, and any residual effect of the B-device signaling SRP on Vbus, the B-device must assume that Vbus above the B-device session threshold is due to A-device driving it high.
The B-device is required to complete its SRP activities in less than TB_SRP_INIT max. On entry to this state, the B-device shall provide an indication to the user that it is trying to establish communications with the A-device and a timer is started. This timer will continue to run until the B-device enters the b_peripheral state. If the timer reaches a vendor specific limit between TB_SRP_FAIL min and TB_SRP_FAIL max the B-device will indicate to the user that the A-device did not respond.
6.8.2.3 b_peripheral
In this state, the On-The-Go B-device acts as the peripheral, and responds to requests from the A-device.
If the On-The-Go B-device wishes to assume the role of Host (b_bus_req = TRUE) and the A-device has granted the On-The-Go B-device permission (b_hnp_enable = TRUE) and the bus is in the Suspend state, then the On-The-Go B-device transitions to the b_wait_acon state. In the event that the On-The-Go B-device started the session with an SRP request, the On-The-Go B-device shall transition to the b_wait_acon state within the TA_AIDL_BDIS timeout, even if b_bus_req is FALSE at the time of transition.
If a Micro-A plug is inserted (id = FALSE) or if VBUS drops below the B-device Session Valid threshold (b_sess_vld = FALSE), then the On-The-Go B-device transitions to the b_idle state.
When a high-speed capable B-device enters this state it shall enable its pull-up on D+. After the B-device enables its pull-up, it must monitor the state of the bus to determine if a bus reset is being signaled by the A-device. If the pull-up is turned on for TWTRSTHS (Table 7-14 in USB 2.0 specification [USB2.0]) and the bus is in the SE0 state then a reset condition exists. (Note: The TWRTSTHS is a sample point that occurs at a device dependent time after the pull-up resistor is turned on.) If the B-device is capable of HS, it shall begin the high-speed detection handshake any time that a bus reset condition exists.
6.8.2.4 b_wait_acon
In this state, the On-The-Go B-device has received a SetFeature(b_hnp_enable) giving it permission to assume the role of Host and it has detected that the bus has gone to the Suspend state. Upon entering this state, the On-The-Go B-device turns off its pull-up resistor on D+, starts a timer (b_ase0_brst_tmr), and waits for the A-device to signal a connect.
The On-The-Go B-device returns to the b_peripheral state:
• if the b_ase0_brst_tmr expires (b_ase0_brst_tmout = TRUE), or
• if the B-device detects a K_state on the bus, indicating that the A-device is signaling a resume (a_bus_resume = TRUE)
If the A-device signals a connect (a_conn = TRUE) before the b_ase0_brst_tmr expires, then the B-device transitions to the b_host state. The B-device shall be able to detect the connect from the A-device and transition to the b_host state within TB_ACON_BSE0 max after D+ is detected to be high at the B-device.
If a Micro-A plug is inserted (id = FALSE) or VBUS drops below the session valid threshold (b_sess_vld = FALSE), then the On-The-Go B-device transitions to the b_idle state.
6.8.2.5 b_host
Upon entering this state, the B-device issues a bus reset, and starts generating SOF’s. The B-device may query the A-device for its descriptors.
While the B-device is in this state, the A-device responds to requests from the B-device. If the B-device does not support the A-device, then the B-device shall provide a message to the user informing them of this.
Once the B-device has completed its usage of the A-device (b_bus_req = FALSE), or if the B-device detects that the A-device has signaled a disconnect (a_conn = FALSE), or within 30 seconds of the On-The-Go B-device detecting that the test device (defined in section 6.6.6) is attached, then the B-device stops generating bus activity (loc_sof = FALSE) and transitions to the b_peripheral state.
If a Micro-A plug is inserted (id = FALSE) or VBUS drops below the B-device Session Valid threshold (b_sess_vld = FALSE), then the On-The-Go B-device transitions to the b_idle state.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值