Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

Version 1 Current »

µC/USB-Device requires two tasks: One core task and one optional task for tracing debug events. The core task has three main responsibilities:

  • Process USB bus events: Bus events such as reset, suspend, connect and disconnect are processed by the core task. Based on the type of bus event, the core task sets the state of the device.
  • Process USB requests: USB requests are sent by the host using the default control endpoint. The core task processes all USB requests. Some requests are handled by the USB class driver, for those requests the core calls the class-specific request handler.
  • Process I/O asynchronous transfers: Asynchronous I/O transfers are handled by the core. Under completion, the core task invokes the respective callback for the transfer.

shows a simplified task model of µC/USB-Device along with application tasks.

Sending and Receiving Data

shows a simplified task model of µC/USB-Device when data is transmitted and received through the USB device controller. With µC/USB-Device, data can be sent asynchronously or synchronously. In a synchronous operation, the application blocks execution until the transfer operation completes, or an error or a time-out has occurred. In an asynchronous operation, the application does not block and several transfers on a same endpoint can be queued, if the driver allows it. The core task notifies the application when the transfer operation has completed through a callback function.

Processing Setup Packets (USB Requests)

USB requests are processed by the core task.  shows a simplified task diagram of a USB request processing.

Processing Bus Events

USB bus events such as reset, resume, connect, disconnect, and suspend are processed in the same way as the USB requests. The core processes the USB bus events to modify and update the current state of the device. The application can be notified of any bus event by registering a callback function via the Bus Event callback structure. shows a simplified diagram of the USB events process.

Bus Event Callback Structure

This structure allows the application to register callback functions that will be called whenever a bus event happens, allowing the user to implement any application-specific action depending on the bus event. The address of this structure must be passed as a parameter to USBD_DevAdd(). See the Modify USB Application Initialization Code section for more details on the initialization of a device or the Application Callback Functions API reference for more details on these callback functions. The  gives details about when a callback is executed based on the device states detailed by Figure 9-1 in the USB 2.0 Specification.

shows a sample bus event callback structure.

Processing Debug Events

µC/USB-Device contains an optional debug and trace feature. Debug events are managed in the core layer using a dedicated task.  shows how the core manages debug events.

For more information on the debug and trace module, see the Debug and Trace page.

  • No labels