Interrupt Service Routine (ISR) Flowcharts
13-96
13.6.6 Device States Changed Handler
This section describes how USB device states and transitions states are
decoded by the USB function and how they can be handled.
The state machine (see Figure 13–21) moves the USB function device from
one state to another state with respect to USB1.1 specification. Attach/
unattach transition is not shown in the transition flow.
Since the SET_CONFIGURATION is not decoded by the core, the local host
has the responsibility to distinguish a SET_CONFIGURATION with a non-valid
configuration value from other SET_CONFIGURATION requests and to set
the Dev_Cfg only if configuration value is valid (value 0 is non-valid), when
device is in addressed state. When device is in configured state, the local host
has the responsibility to set the Clr_Cfg if configuration number is 0 so that the
device moves to addressed state.
Device states are visible in DEVSTAT register and are decoded as follows:
-
Attached: The device is attached to the USB and powered.
-
Default: The device is attached to the USB, powered, and reset.
-
Addressed: The device is attached to the USB, powered, reset, and an
address has been assigned. The device moves into the addressed state
after a SET_ADDRESS request with an address number different of 0.
-
Configured: The device is attached to the USB, powered, reset, has an
address different from 0, and is configured. The device moves into the
configured state after a valid SET_CONFIGURATION request only if the
local HOST has set the Dev_Cfg bit (meaning the configuration is valid).
-
Suspended: Device is at minimum default and has not seen bus activity
for 5 ms.
-
Reset: When set, the device is receiving a valid USB host reset.
-
R_WK_OK: This bit is set/cleared automatically after a valid
SET_DEVICE_FEATURE/CLEAR_DEVICE_FEATURE request,
respectively.
Any change in the DEVSTAT register bits triggers a device change interrupt
(the DS_Chg) if enabled.
The device moves to addressed state after the status stage of a valid SET_
ADDRESS, even if the status stage ACK handshake is received
corrupted or not sent by the USB host. A SET_DEVICE_FEATURE or a
CLEAR_DEVICE_FEATURE is effective after setup transaction, even if no
status stage occurs. A SET_CONFIGURATION request is effective before
status stage, when the local host sets the Clr_Cfg or the DEV_Cfg bit.