USB Device Controller interface. More...
#include <bitops.h>#include <usb/usb_protocol.h>Go to the source code of this file.
Data Structures | |
| struct | udc |
| A USB Device Controller. More... | |
Typedefs | |
| typedef int8_t | usb_ep_id_t |
| Endpoint identifier. | |
Enumerations | |
| enum | udc_flag { UDC_IS_ENABLED, UDC_AUTOATTACH, UDC_HAS_POWER, UDC_IS_SUSPENDED } |
Bit definitions for udc::flags. More... | |
Functions | |
UDC Library Interface | |
| void | udc_set_address (struct udc *udc, unsigned int addr) |
| Signal that the UDC is to change its USB address after the status IN phase is complete. | |
Initialization | |
| struct udc * | udc_init (void) |
| Initialize the USB Device Controller. | |
Device State | |
| static bool | udc_is_high_speed (struct udc *udc) |
| Test whether the USB Device Controller is running at high speed. | |
| static bool | udc_is_full_speed (struct udc *udc) |
| Test whether the USB Device Controller is running at full speed. | |
| static bool | udc_is_low_speed (struct udc *udc) |
| Test whether the USB Device Controller is running at low speed. | |
| static enum usb_device_state | udc_state (struct udc *udc) |
| Figure out which usb_device_state the device is in. | |
| void | udc_attach (struct udc *udc) |
| Attach udc to the bus when possible. | |
| void | udc_detach (struct udc *udc) |
| Detach udc from the bus. | |
Endpoint Management | |
The following functions allow drivers to create and destroy endpoints, as well as set, clear and query their "halted" and "wedged" states. Wedging an endpoint is useful when encountering errors that need some sort of error recovery procedure to be performed by the host. A wedged endpoint behaves like one that is halted, except that the host is prevented from clearing the halted state through the standard ClearFeature(HALT) request. This behaviour is required by the USB Mass Storage Bulk-Only Transport specification. | |
| usb_ep_id_t | udc_ep_create_bulk (struct udc *udc, uint8_t addr, uint16_t max_packet_size) |
| Create a new Bulk endpoint. | |
| usb_ep_id_t | udc_ep_create_interrupt (struct udc *udc, uint8_t addr, uint16_t max_packet_size) |
| Create a new Interrupt endpoint. | |
| void | udc_ep_destroy (struct udc *udc, usb_ep_id_t ep) |
| Destroy a previously created endpoint. | |
| status_t | udc_ep_clear_halt (struct udc *udc, usb_ep_id_t ep) |
| Clear the halted state of the endpoint ep. | |
| status_t | udc_ep_set_halt (struct udc *udc, usb_ep_id_t ep) |
| Set the halted state of the endpoint ep. | |
| status_t | udc_ep_is_halted (struct udc *udc, usb_ep_id_t ep) |
| Check if the endpoint ep is halted. | |
| void | udc_ep_clear_wedge (struct udc *udc, usb_ep_id_t ep) |
| Clear the wedged state of an endpoint. | |
| void | udc_ep_set_wedge (struct udc *udc, usb_ep_id_t ep) |
| Set the wedged state of an endpoint. | |
| bool | udc_ep_is_wedged (struct udc *udc, usb_ep_id_t ep) |
| Check if a given endpoint is wedged. | |
| void | udc_ep_flush (struct udc *udc, usb_ep_id_t ep) |
| Terminate all pending requests on an endpoint. | |
Control Transfer | |
The following functions are used to send and receive packets over the default control endpoint, ep0. Most functions are asynchronous and will call a callback function after the transfer is done. The only exception is udc_ep0_write_sync(), which will write the data to the FIFO immediately and busy-wait until it has been sent. | |
| void | udc_ep0_submit_out_req (struct udc *udc, struct usb_request *req) |
| Submit an OUT request on the default control endpoint. | |
| void | udc_ep0_submit_in_req (struct udc *udc, struct usb_request *req) |
| Submit an IN request on the default control endpoint. | |
| status_t | udc_ep0_write_sync (struct udc *udc, const void *data, size_t len) |
| Transmit IN data on the default control endpoint synchronously. | |
| void | udc_ep0_send_status (struct udc *udc) |
| Send a status IN packet on the default control endpoint. | |
| void | udc_ep0_expect_status (struct udc *udc) |
| Signal that a status OUT packet is expected on the default control endpoint. | |
Data Transfer | |
| void | udc_ep_submit_out_req (struct udc *udc, usb_ep_id_t ep, struct usb_request *req) |
| Submit an OUT request on a non-control endpoint. | |
| void | udc_ep_submit_in_req (struct udc *udc, usb_ep_id_t ep, struct usb_request *req) |
| Submit an IN request on a non-control endpoint. | |
USB Device Controller interface.
This file contains functions and data structures common to all USB Device Controller implementations.
Copyright (C) 2009 Atmel Corporation. All rights reserved.
Definition in file udc.h.
1.6.3