Functions
usb_dwc_dcd.c File Reference

DWC3 device controller driver. This is the lowest layer driver which interacts directly with the hardware. More...

#include "types.h"
#include "hw_types.h"
#include "usb_dwc_dcd.h"
#include "error.h"

Functions

uint32_t usbDwcDcdGetEvntCount (usbDwcDcdDevice_t *dwc3, uint32_t evntId)
 This API returns the number of events for a selected buffer. More...
 
void usbDwcDcdSetupEvntBuf (usbDwcDcdDevice_t *dwc3, usbDwcDcdEvnt_t *pUsbEvnt, uint32_t evntSize, uint32_t count, uint32_t eventId)
 Setup Event buffer required by the device control driver. More...
 
void usbDwcDcdCoreInit (usbDwcDcdDevice_t *dwc3)
 USB DWC3 device controller drive core reset API. More...
 
void usbDwcDcdRunDEpCmd (usbDwcDcdDevice_t *dwc3, uint32_t phEpId, usbDEpCmdType_t pDEpCmdType, usbDwcDcdDEpCmdParms_t *pDEpCmdParm, int32_t rscIdx, uint8_t *pStatus)
 This API is used to run Device endpoint command. More...
 
void usbDwcDcdRunSetupXfer (usbDwcDcdDevice_t *dwc3)
 This API prepare a buffer for setup packet, initialise a setup TRB and starts the transfer. More...
 
void usbDwcDcdRunXferSingle (usbDwcDcdDevice_t *dwc3, uint32_t phEpId, usbDEpTrb_t *pTrb, void *pBuf, uint32_t bufSize, usbDwcDcdTrbCtrl_t xferType)
 Run a start transfer command for single TRB. More...
 
void usbDwcDcdStartXfer (usbDwcDcdDevice_t *dwc3, uint32_t phEpId, usbDEpTrb_t *pDEpTrb)
 Runs a start transfer core command with the provided transfer descriptor. More...
 
void usbDwcDcdRstEvntHandler (usbDwcDcdDevice_t *dwc3)
 Perform the core operations required on receiving USB reset Event. More...
 
void usbDwcDcdCnctDoneEvntHandler (usbDwcDcdDevice_t *dwc3)
 Perform the operations required on connect done event. More...
 
void usbDwcDcdEp0EvntHandler (usbDwcDcdDevice_t *dwc3, usbDwcDcdEvnt_t *usbDwcDcdEvnt)
 EP0 interrupt handler(Default control endpoint) All other endpoint interrupts are handled separetely. More...
 
void usbDwcDcdEpEvntHandler (usbDwcDcdDevice_t *dwc3, usbDwcDcdEvnt_t *usbDwcDcdEvnt)
 usb endpoint event handler which handles the various endpoint events of the DWC3 controler. More...
 
void usbDwcDcdDevEvntHandler (usbDwcDcdDevice_t *dwc3, usbDwcDcdEvnt_t *usbDwcDcdEvnt)
 usb device event handler which handler the various events of the DWC3 controller. More...
 
void usbDwcDcdSetEpStall (usbDwcDcdDevice_t *dwc3, uint32_t phEpId, uint32_t flag)
 This function sets or clear endpoint stall. More...
 
void usbDwcDcdSetConfiguration (usbDwcDcdDevice_t *dwc3)
 This API is called when the set configuration request comes from the host driver. More...
 
static usbDwcDcdDEpCmdParms_t dEpCmdParm __attribute__ ((aligned(32U)))
 usb endpoint command parameters More...
 
uint32_t USBDwcDcdInit (struct usbDcd *pDcdObject)
 USB DWC3 device controller driver core init API. More...
 
uint32_t USBDwcDcdConfigDevChara (struct usbDcd *pDcdObject, usbDevChara_t *pDevCharecteristic)
 This API sets the device characteristics. More...
 
uint32_t USBDwcDcdEp0Req (struct usbDcd *pDcdObject, usbEndpt0Request_t req)
 Endpoint 0 request for control endpoint. More...
 
uint32_t USBDwcDcdEpReq (struct usbDcd *pDcdObject, usbEndptRequest_t req)
 Endpoint request for control bulk and isoch transfers for all endpoints other than endpoint 0. More...
 
uint32_t USBDwcDcdIntrHandler (usbDwcDcdDevice_t *dwc3)
 USB DWC3 device interrupt handler. This will get all the device and endpoint events for all the endpoints. More...
 

Detailed Description

DWC3 device controller driver. This is the lowest layer driver which interacts directly with the hardware.

Function Documentation

static usbDEpTrb_t bulkOutTrb __attribute__ ( (aligned(32U))  )
static

usb endpoint command parameters

Control data buffer.

USB event buffer.

TRB for bulk out transfers.

TRB for bulk in transfers.

TRB for control status commands.

TRB for transfer of control data.

void usbDwcDcdCnctDoneEvntHandler ( usbDwcDcdDevice_t dwc3)

Perform the operations required on connect done event.

Parameters
dwc3Pointer to the dwc3 device object
uint32_t USBDwcDcdConfigDevChara ( usbDcd_t pDcdObject,
usbDevChara_t pDevCharacteristic 
)

This API sets the device characteristics.

Parameters
pDcdObjectpointer to the USB device control object.
pDevCharacteristicpointer to the device characteristics structure.
void usbDwcDcdCoreInit ( usbDwcDcdDevice_t dwc3)

USB DWC3 device controller drive core reset API.

Parameters
dwc3pointer to the dwc3 device object.
void usbDwcDcdDevEvntHandler ( usbDwcDcdDevice_t dwc3,
usbDwcDcdEvnt_t usbDwcDcdEvnt 
)

usb device event handler which handler the various events of the DWC3 controller.

Parameters
dwc3pointer to the dwc3 device object
usbDwcDcdEvntpointer to the DWC3 device event which has occured.

More events can be added when required

void usbDwcDcdEp0EvntHandler ( usbDwcDcdDevice_t dwc3,
usbDwcDcdEvnt_t usbDwcDcdEvnt 
)

EP0 interrupt handler(Default control endpoint) All other endpoint interrupts are handled separetely.

Parameters
dwc3pointer to the dwc3 device object
usbDwcDcdEvntThe event which is to be processed
uint32_t USBDwcDcdEp0Req ( usbDcd_t pDcdObject,
usbEndpt0Request_t  req 
)

Endpoint 0 request for control endpoint.

Parameters
pDcdObjectpointer to the USB device control object.
reqUSB request which needs to be handled for endpoint 0
void usbDwcDcdEpEvntHandler ( usbDwcDcdDevice_t dwc3,
usbDwcDcdEvnt_t usbDwcDcdEvnt 
)

usb endpoint event handler which handles the various endpoint events of the DWC3 controler.

Parameters
dwc3pointer to the dwc3 device object.
usbDwcDcdEvntpointer to the DWC3 endpoint event which has occured.
uint32_t USBDwcDcdEpReq ( usbDcd_t pDcdObject,
usbEndptRequest_t  req 
)

Endpoint request for control bulk and isoch transfers for all endpoints other than endpoint 0.

Parameters
pDcdObjectpointer to the USB device control object.
reqUSB request which needs to be handled for endpoint other than endpoint 0.
uint32_t usbDwcDcdGetEvntCount ( usbDwcDcdDevice_t dwc3,
uint32_t  evntId 
)

This API returns the number of events for a selected buffer.

Parameters
dwc3pointer to the dwc3 device object.
evntIdID of the event buffer.
uint32_t USBDwcDcdInit ( usbDcd_t pDcdObject)

USB DWC3 device controller driver core init API.

Parameters
pDcdObjectpointer to the USB device control driver object
uint32_t USBDwcDcdIntrHandler ( usbDwcDcdDevice_t dwc3)

USB DWC3 device interrupt handler. This will get all the device and endpoint events for all the endpoints.

Parameters
dwc3pointer to the dwc3 object
void usbDwcDcdRstEvntHandler ( usbDwcDcdDevice_t dwc3)

Perform the core operations required on receiving USB reset Event.

Parameters
dwc3pointer to the dwc3 device object
void usbDwcDcdRunDEpCmd ( usbDwcDcdDevice_t dwc3,
uint32_t  phEpId,
usbDEpCmdType_t  pDEpCmdType,
usbDwcDcdDEpCmdParms_t pDEpCmdParm,
int32_t  rscIdx,
uint8_t *  pStatus 
)

This API is used to run Device endpoint command.

Parameters
dwc3pointer to the dwc3 device object
phEpIdId of the physical endpoint
usbDEpCmdEndpoint command to be issued
pDEpCmdParmEndpoint command parameters
rscIdxResource Idx value for Set New config command 0 for RSCIDX = 0 2 for RSCIDX = 2 -1 Don't Care
void usbDwcDcdRunSetupXfer ( usbDwcDcdDevice_t dwc3)

This API prepare a buffer for setup packet, initialise a setup TRB and starts the transfer.

Parameters
dwc3pointer to the dwc3 device object.
void usbDwcDcdRunXferSingle ( usbDwcDcdDevice_t dwc3,
uint32_t  phEpId,
usbDEpTrb_t *  pTrb,
void *  pBuf,
uint32_t  bufSize,
usbDwcDcdTrbCtrl_t  xferType 
)

Run a start transfer command for single TRB.

Parameters
dwc3pointer to the dwc3 device object
phEpIdtarget physical endpoint ID
pTrbpointer to the TRB
pBufpointer to the data buffer
bufSizeSize of the data buffer
xferTypeTransfer type
void usbDwcDcdSetConfiguration ( usbDwcDcdDevice_t dwc3)

This API is called when the set configuration request comes from the host driver.

Parameters
dwc3pointer to the dwc3 device object
void usbDwcDcdSetEpStall ( usbDwcDcdDevice_t dwc3,
uint32_t  phEpId,
uint32_t  flag 
)

This function sets or clear endpoint stall.

Parameters
dwc3pointer to the dwc3 device object
phEpIdPhysical endpoint number for which the stall has to be set or cleared.
flag- TRUE - set stall flag - FLASE - clear stall
void usbDwcDcdSetupEvntBuf ( usbDwcDcdDevice_t dwc3,
usbDwcDcdEvnt_t pUsbEvnt,
uint32_t  evntSize,
uint32_t  count,
uint32_t  eventId 
)

Setup Event buffer required by the device control driver.

Parameters
dwc3pointer to the dwc3 device object
pUsbEvntpointer to the USB event buffer
evntSizesize of the USB event buffer
countcount of the USB buffers
eventIdID of the event buffer
void usbDwcDcdStartXfer ( usbDwcDcdDevice_t dwc3,
uint32_t  phEpId,
usbDEpTrb_t *  pDEpTrb 
)

Runs a start transfer core command with the provided transfer descriptor.

Parameters
dwc3pointer to the dwc3 device object
phEpIdPhysical endpoint ID
pDEpTrbPointer to the Endpoint TRB

Copyright 2016, Texas Instruments Incorporated