Specifications

7
6263A–ATARM–10-Oct-06
Application Note
Resume, when the bus becomes active again
Reset, when an end-of-bus reset is detected
NewRequest, when a setup packet is received on a control endpoint
StartOfFrame, every 1 ms (for full-speed controllers) or 125 µs (for high-speed controllers)
More information about these callbacks and their expected behavior can be found in Section 3.4
on page 8.
3.3.3 Endpoint Behavior Modification
The USB API offers three functions to control how an endpoint operates.
The first one is used to actually configure the endpoint, and must thus be called prior to using
any other endpoint-related function. The other two provide ways to modify how an endpoint
acknowledges incoming packets.
3.3.3.1 USB_ConfigureEndpoint
This function is used to configure an endpoint at the USB controller level. An appropriate end-
point descriptor must be provided to do that. The descriptor is used to configure the endpoint
type (either Control, Bulk, Interrupt or Isochronous), direction (IN or OUT) and address.
Control endpoint 0 is automatically configured by the USB API when the End of bus reset event
is signalled by the USB controller. Therefore, there is no need to do it manually.
3.3.3.2 USB_Stall
The USB_Stall method causes an endpoint to acknowledge its next received packet with a
STALL handshake. Further packets are then handled normally.
Most of the time, this method should be used with endpoint 0 to signal the host that the device
cannot process a command.
3.3.3.3 USB_Halt
This method sets, clears or gets the Halt status of an endpoint (depending on the request
parameter). When in Halt mode, every received packet is acknowledged with a STALL hand-
shake instead of being handled normally.
USB_Halt can be called either with the USB_SET_FEATURE, USB_CLEAR_FEATURE or
USB_GET_STATUS parameter to modify the endpoint Halt state.
3.3.4 Data Transfer
Data transfer (IN or OUT) on an endpoint can be performed by calling two methods, USB_Write
and USB_Read.
3.3.4.1 USB_Write
The USB_Write function sends a data payload on a specific endpoint. If the data payload equals
or exceeds the maximum packet size of the endpoint, then several IN transactions are neces-
sary. This method should only be called on an IN or Control endpoint.
The write is performed asynchronously, i.e., the function returns immediately without waiting
for the transfer to finish. When the transfer is complete, an optional user-provided callback func-
tion is called. This makes it possible to create an OS-friendly synchronous function by locking
and unlocking a semaphore before and after each write.