
IX PERIPHERAL MODULES 7 (USB): USB FUNCTION CONTROLLER (USB)
IX-1-14
EPSON
S1C33E07 TECHNICAL MANUAL
SETUP stage
The macro automatically executes a SETUP transaction upon reception of a SETUP token addressed to its own
node. Have your firmware monitor a RcvEP0SETUP status and analyze the request referring to the EP0Setup_0
through EP0Setup_7 registers to control “control transfer”.
If the host has received a request that involves an OUT data stage, clear the INxOUT bit of the EP0Control
register to set the EP0 endpoint direction to OUT.
If the host has received a request that involves an IN data stage, set the INxOUT bit of the EP0Control register
to set the EP0 endpoint direction to IN.
If the host has received a request that involves no data stage, set the INxOUT bit of the EP0Control register to
set the EP0 endpoint direction to IN in order to transit to a status stage.
Data stage/status stage
Transit to the next stage according to the result of request analysis executed by reading the EP0Setup_0 through
EP0Setup_7 registers.
If it is an OUT stage, clear the INxOUT of the EP0Control register to set the direction to OUT and control the
stage by setting the EP0ControlOUT accordingly. When the SETUP stage is completed, the ForceNAK bit is
set.
If it is an IN stage, set the INxOUT of the EP0Control register to set the direction to IN and control the stage by
setting the EP0ControlIN accordingly. When the SETUP stage is completed, the ForceNAK bit is set.
Automatic address setting function
This macro provides an automatic address setting function when processing a SetAddress() request in a control
transfer at the EP0 endpoint.
This function is available for the firmware when the EP0Setup_0 through EP0Setup_7 registers are checked to
confirm the contents and it is proven to be a valid SetAddress() request.
If it is determined to be a valid SetAddress() request, clear or set the EP0ControlIN.ForceNAK and
EP0ControlIN.EnShortPkt bits accordingly and set the USB_Address.AutoSetAddress bit before responding to
the status stage.
After this function is enabled and the IN transaction at the EP0 endpoint is completed, the macro extracts the
address from the data in the SetAddress() request and sets it on the USB_Address.USB_Address bit.
Meanwhile, a SetAddressCmp status (SIE_IntStat.SetAddressCmp bit) is issued to the firmware.
After this function is enabled, if any other transaction is invoked at the EP0 endpoint before an IN transaction
is executed, this function is cancelled and the USB_Address.AutoSetAddress bit is cleared. Accordingly, a
SetAddressCmp status is not issued to the firmware.
Descriptor return function
This macro provides a descriptor return function that is useful for an request that requires data and is issued
more than once during control transfer at the EP0 endpoint (for example, during a GetDescriptor() request).
The firmware can use this function for a request that involves an IN data stage.
Clear the EP0ControlIN.ForceNAK bit, and before starting responding to the data stage, set the top address of
the data to be returned that is within the FIFO's descriptor region on the DescAdrs_H, L register as well as the
total number of bytes in the return data on the DescSize_H, L register and set the EP0Control.ReplyDescriptor
bit.
The descriptor return function executes IN transactions by returning data packets in response to IN transactions
until it finishes sending all of a specified number of data. If a fractional number of data exist against the
maximum packet size, the descriptor return function sets EP0ControlIN.EnShortPkt, enabling response to IN
transactions until the entire data return is completed.
After returning all the specified number of data, the macro clears the EP0Control.ReplyDescriptor bit and
issues a DescriptorCmp status (FIFO_IntStat.DescriptorCmp bit) to the firmware.
For details of the descriptor region, see the section on the FIFO in the functional description.