AM261x MCU+ SDK  11.00.00
no_os_gadget.c File Reference

Introduction

Application-specific Function Driver interface

Simple applications may wish to implement their entire Function Driver here.

More complex applications, or environments with an existing Function Driver framework (such as the Linux Gadget framework) will implement the interface to their Function Driver here.

See the linux/ subdirectory for an example implementation of a Linux Gadget framework interface.

For historical reasons, the PCD API uses the Linux term "gadget" to refer to a Function Driver.

Functions

int dwc_usb3_gadget_connect (volatile dwc_usb3_pcd_t *pcd, int speed)
 This routine receives Connect notifications from the PCD. More...
 
int dwc_usb3_gadget_disconnect (volatile dwc_usb3_pcd_t *pcd)
 This routine receives Disconnect notifications from the PCD. More...
 
int dwc_usb3_gadget_suspend (volatile dwc_usb3_pcd_t *pcd)
 This routine receives Suspend notifications from the PCD. More...
 
int dwc_usb3_gadget_resume (volatile dwc_usb3_pcd_t *pcd)
 This routine receives Resume notifications from the PCD. More...
 
int dwc_usb3_gadget_setup (volatile dwc_usb3_pcd_t *pcd, usb_device_request_t *ctrl)
 This routine receives Setup request notifications from the PCD. More...
 
int dwc_usb3_gadget_complete (volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *pcd_ep, volatile dwc_usb3_pcd_req_t *pcd_req, int status)
 This routine receives Transfer Complete notifications from the PCD. More...
 
void * dwc_usb3_gadget_alloc_dma (volatile dwc_usb3_pcd_ep_t *pcd_ep, int size, dwc_dma_t *mem_dma_ret)
 This routine allocates coherent DMA memory. It is used by the PCD to allocate memory for TRBs. The block of memory returned must have a start address aligned to a 16-byte boundary. More...
 
void dwc_usb3_gadget_free_dma (volatile dwc_usb3_pcd_ep_t *pcd_ep, int size, void *mem, dwc_dma_t mem_dma)
 This routine frees DMA memory allocated by dwc_usb3_gadget_alloc_dma(). More...
 
dwc_usb3_pcd_req_tdwc_usb3_gadget_get_request (volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *pcd_ep)
 This routine returns the PCD request corresponding to the current transfer request for an endpoint. The current transfer request is the first request submitted that has not been completed yet. More...
 
void dwc_usb3_gadget_start_next_request (volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *pcd_ep)
 This routine checks to see if there is another transfer request waiting on an endpoint that has not been started yet. If so then that transfer is started. More...
 
void dwc_usb3_gadget_isoc_ep_start (volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *pcd_ep, u32 event)
 This routine starts an Isoc EP running at the proper interval, after receiving the initial XferNrdy event. More...
 
void dwc_usb3_gadget_request_nuke (volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *pcd_ep)
 This routine terminates all requests which are pending on an endpoint. More...
 
void dwc_usb3_gadget_set_ep_not_started (volatile dwc_usb3_pcd_t *pcd, volatile dwc_usb3_pcd_ep_t *pcd_ep)
 This routine marks all pending requests for an EP as not started. More...
 
volatile usb_ep_tdwc_usb3_ep_enable (struct dwc_usb3_device *usb3_dev, const void *epdesc, const void *epcomp)
 
int dwc_usb3_ep_disable (volatile struct dwc_usb3_device *usb3_dev, volatile usb_ep_t *usb_ep)
 
int dwc_usb3_close_all_ep (volatile struct dwc_usb3_device *usb3_dev)
 
usb_request_tdwc_usb3_alloc_request (struct dwc_usb3_device *usb3_dev, volatile usb_ep_t *usb_ep)
 
void dwc_usb3_free_request (struct dwc_usb3_device *usb3_dev, volatile usb_ep_t *usb_ep, volatile usb_request_t *usb_req)
 
int dwc_usb3_ep_queue (struct dwc_usb3_device *usb3_dev, volatile usb_ep_t *usb_ep, usb_request_t *usb_req)
 
int dwc_usb3_ep_dequeue (struct dwc_usb3_device *usb3_dev, usb_ep_t *usb_ep, usb_request_t *usb_req)
 
int dwc_usb3_gadget_init (dwc_usb3_device_t *usb3_dev)
 
void dwc_usb3_gadget_remove (dwc_usb3_device_t *usb3_dev)
 

Variables

dwc_usb3_device_t g_usb3_dev
 
dwc_usb3_pcd_req_t g_pcd_req []
 
u32 g_pcd_req_bm
 
dwc_usb3_dma_desc_t g_out_trb_pool [][DWC_NUM_ISOC_TRBS+1]
 
dwc_usb3_dma_desc_t g_in_trb_pool [][DWC_NUM_ISOC_TRBS+1]
 

Function Documentation

◆ dwc_usb3_ep_enable()

volatile usb_ep_t* dwc_usb3_ep_enable ( struct dwc_usb3_device *  usb3_dev,
const void *  epdesc,
const void *  epcomp 
)

This routine enables a USB endpoint

Parameters
usb3_devProgramming view of DWC_usb3 device.
epdescUSB endpoint descriptor for the EP.
epcompUSB SS endpoint companion descriptor for the EP.
Returns
Pointer to USB EP context, or NULL on failure.

◆ dwc_usb3_ep_disable()

int dwc_usb3_ep_disable ( volatile struct dwc_usb3_device *  usb3_dev,
volatile usb_ep_t usb_ep 
)

This routine disables a USB endpoint

Parameters
usb3_devProgramming view of DWC_usb3 device.
usb_epUSB EP to disable.
Returns
0 for success, else negative error code.

◆ dwc_usb3_close_all_ep()

int dwc_usb3_close_all_ep ( volatile struct dwc_usb3_device *  usb3_dev)

This routine disables a all active non EP-0 USB endpoint

Parameters
usb3_devProgramming view of DWC_usb3 device.
Returns
0 for success, else negative error code.

◆ dwc_usb3_alloc_request()

usb_request_t* dwc_usb3_alloc_request ( struct dwc_usb3_device *  usb3_dev,
volatile usb_ep_t usb_ep 
)

This routine allocates a USB request object to use with the specified USB endpoint. The contents of a USB request are defined by the Function Driver, and are opaque to the PCD. The USB request is embedded inside of an enclosing PCD request object (see the definition of struct dwc_usb3_pcd_req in pcd.h). One request object is needed for each transfer that is submitted to the PCD.

Parameters
usb3_devProgramming view of DWC_usb3 device.
usb_epUSB EP for the request.

◆ dwc_usb3_free_request()

void dwc_usb3_free_request ( struct dwc_usb3_device *  usb3_dev,
volatile usb_ep_t usb_ep,
volatile usb_request_t usb_req 
)

This routine frees a USB request object

Parameters
usb3_devProgramming view of DWC_usb3 device.
usb_epUSB EP for the request.
usb_reqUSB request to be freed.

◆ dwc_usb3_ep_queue()

int dwc_usb3_ep_queue ( struct dwc_usb3_device *  usb3_dev,
volatile usb_ep_t usb_ep,
usb_request_t usb_req 
)

This routine submits a transfer request for a USB endpoint. The example code maintains a queue of requests for each endpoint, so that the application can start another transfer on the same endpoint without having to wait for the first transfer to complete.

Parameters
usb3_devProgramming view of DWC_usb3 device.
usb_epUSB EP for the transfer.
usb_reqUSB request for the transfer.
Returns
0 for success, else negative error code.

◆ dwc_usb3_ep_dequeue()

int dwc_usb3_ep_dequeue ( struct dwc_usb3_device *  usb3_dev,
usb_ep_t usb_ep,
usb_request_t usb_req 
)

This routine cancels a transfer request for a USB endpoint. This is only needed in exceptional cases, a normal transfer completion does not require this.

Parameters
usb3_devProgramming view of DWC_usb3 device.
usb_epUSB EP for the transfer.
usb_reqUSB request for the transfer.
Returns
0 for success, else negative error code.

◆ dwc_usb3_gadget_init()

int dwc_usb3_gadget_init ( dwc_usb3_device_t usb3_dev)

Function Driver initialization routine

Parameters
usb3_devProgramming view of DWC_usb3 device.
Returns
0 for success, else negative error code.

◆ dwc_usb3_gadget_remove()

void dwc_usb3_gadget_remove ( dwc_usb3_device_t usb3_dev)

Function Driver removal routine

Parameters
usb3_devProgramming view of DWC_usb3 device.

Variable Documentation

◆ g_usb3_dev

dwc_usb3_device_t g_usb3_dev
extern

Driver context struct - defined in no_os_init.c

◆ g_pcd_req

dwc_usb3_pcd_req_t g_pcd_req[]
extern

PCD request pool - defined in no_os_init.c

◆ g_pcd_req_bm

u32 g_pcd_req_bm
extern

◆ g_out_trb_pool

dwc_usb3_dma_desc_t g_out_trb_pool[][DWC_NUM_ISOC_TRBS+1]
extern

DMA descriptor (TRB) pools for non-EP0 EPs - defined in no_os_init.c

◆ g_in_trb_pool

dwc_usb3_dma_desc_t g_in_trb_pool[][DWC_NUM_ISOC_TRBS+1]
extern