28 USB FUNCTION CONTROLLER (USB)
28-8
Seiko Epson Corporation
S1C33L26 TECHNICAL MANUAL
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 EP-
0ControlIN.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 transac-
tion is executed, this function is canceled and the USB_Address.AutoSetAddress bit is cleared. Accord-
ingly, a SetAddressCmp status is not issued to the firmware.
Descriptor return function
This macro provides a descriptor return function that is useful for a 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.Reply-
Descriptor bit.
The descriptor return function executes IN transactions by returning data packets in response to IN transac-
tions 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.
Bulk transfer/interrupt transfer
Bulk and interrupt transfers at the general-purpose endpoints, EPa, EPb, EPc, and EPd, can be controlled either
as a data flow (see the “Data flow control” section) or as a series of discrete transactions (see the “Transaction”
section).
Data flow control
This section describes controlling standard data flows in OUT and IN transfers.
OUT transfer
Data received from an OUT transfer are placed on the FIFO region at the respective endpoints. The FIFO
data can be read via either the CPU interface (EP0, EPa, EPb, EPc, EPd) or the Port interface (EPa, EPb,
EPc, EPd).
To read the FIFO data via the CPU interface, select one and only one endpoint using the CPU_JoinRd reg-
ister. The FIFO data of the selected endpoint can be read sequentially with the EPnFIFOforCPU, according
to the order of reception. Also, you can refer to the EPnRdRemain_H and EPnRdRemain_L registers to
check the number of remaining data. Reading from a blank FIFO causes dummy reading to be performed.
To read the FIFO data via the Port interface, select one and only one OUT endpoint using the DMA_Join
register. Perform the Port interface procedure to read the FIFO data of the selected endpoint; they are read
sequentially in the order of reception. Also, you can refer to the DMA_Remain_H and DMA_Remain_L
registers to check the number of remaining data. After the FIFO is emptied, the Port interface automatically
pauses to perform flow control.