【正文】
ayer is the functionality provided by the serial bus device, for instance, a mouse or ISDN interface.This chapter describes the mon attributes and operations of the middle layer of a USB device. These attributes and operations are used by the functionspecific portions of the device to municate through the bus interface and ultimately with the host.1. USB Device StatesA USB device has several possible states. Some of these states are visible to the USB and the host, while others are internal to the USB device. This section describes those states. Visible Device StatesThis section describes USB device states that are externally visible (see Figure 11). Note:USB devices perform a reset operation in response to reset signaling on the upstream facing port. When reset signaling has pleted, the USB device is reset.Figure 11. Device State Diagram AttachedA USB device may be attached or detached from the USB. The state of a USB device when it is detached from the USB is not defined by this specification. This specification only addresses required operations and attributes once the device is attached. PoweredUSB devices may obtain power from an external source and/or from the USB through the hub to which they are attached. Externally powered USB devices are termed selfpowered. Although selfpowered devices may already be powered before they are attached to the USB, they are not considered to be in the Powered state until they are attached to the USB and VBUS is applied to the device.A device may support both selfpowered and buspowered configurations. Some device configurations support either power source. Other device configurations may be available only if the device is selfpowered. Devices report their power source capability through the configuration descriptor. The current power source is reported as part of a device’s status. Devices may change their power source at any time, ., from self to buspowered. If a configuration is capable of supporting both power modes, the power maximum reported for that configuration is the maximum the device will draw from VBUS in either mode. The device must observe this maximum, regardless of its mode. If a configuration supports only one power mode and the power source of the device changes, the device will lose its current configuration and address and return to the Powered state. If a device is selfpowered and its current configuration requires more than 100 mA, then if the device switches to being buspowered, it must return to the Address state. Selfpowered hubs that use VBUS to power the Hub Controller are allowed to remain in the Configured state if local power is lost. A hub port must be powered in order to detect port status changes, including attach and detach. Buspowered hubs do not provide any downstream power until they are configured, at which point they will provide power as allowed by their configuration and power source. A USB device must be able to be addressed within a specified time period from when power is initially applied .After an attachment to a port has been detected, the host may enable the port, which will also reset the device attached to the port. DefaultAfter the device has been powered, it must not respond to any bus transactions until it has received a reset from the bus. After receiving a reset, the device is then addressable at the default address.When the reset process is plete, the USB device is operating at the correct speed (., low/full/highspeed).The speed selection for low and fullspeed is determined by the device termination resistors. A device that is capable of highspeed operation determines whether it will operate at highspeed as a part of the reset process A device capable of highspeed operation must reset successfully at fullspeed when in an electrical environment that is operating at fullspeed. After the device is successfully reset, the device must also respond successfully to device and configuration descriptor requests and return appropriate information. The device may or may not be able to support its intended functionality when operating at fullspeed. AddressAll USB devices use the default address when initially powered or after the device has been reset. Each USB device is assigned a unique address by the host after attachment or after reset. A USB device maintains its assigned address while suspended.A USB device responds to requests on its default pipe whether the device is currently assigned a unique address or is using the default address. ConfiguredBefore a USB device’s function may be used, the device must be configured. From the device’s perspective, configuration involves correctly processing a SetConfiguration() request with a nonzero configuration value. Configuring a device or changing an alternate setting causes all of the status and configuration values associated with endpoints in the affected interfaces to be set to their default values. This includes setting the data toggle of any endpoint using data toggles to the value DATA0.2. Generic USB Device OperationsAll USB devices support a mon set of operations. This section describes those operations. Dynamic Attachment and RemovalUSB devices may be attached and removed at any time. The hub that provides the attachment point or port is responsible for reporting any change in the state of the port.The host enables the hub port where the device is attached upon detection of an attachment, which also has the effect of resetting the device. A reset USB device has the following characteristics:● Responds to the default USB address●Is not configured● Is not initially suspendedWhen a device is removed from a hub port, the hub disables the port where the device was attached and notifies the host of the removal. Address AssignmentWhen a USB device is attached, the host is responsible for assigning a unique address to the device. This is done after the device has