AM261x MCU+ SDK: Endpoint API Routines

| AM261x MCU+ SDK 26.00.00 |

Functions
Endpoint API Routines
APIs for SOC Specific Device Drivers » APIs for USB » APIs for Synopsys driver

## Introduction

These routines handle all the functionality required for configuring, enabling, controlling, and submitting transfers to an endpoint
Note: For Control endpoint 0, only the submit_req, cancel_req, request_done, and set_halt routines are used; the remaining functionality is handled either by the Control Endpoint 0 API Routines below or internally by the PCD.

## Functions
void | dwc_usb3_ep_activate (dwc_usb3_pcd_t *pcd, dwc_usb3_pcd_ep_t *ep, int restore)
| This routine activates an EP. The Device EP control registers for the EP are configured as defined in the EP structure. More...
int | dwc_usb3_pcd_ep_enable (dwc_usb3_pcd_t *pcd, dwc_usb3_pcd_ep_t *ep, const usb_endpoint_descriptor_t *ep_desc, const ss_endpoint_companion_descriptor_t *ep_comp)
| This routine is called by the Function Driver for each EP (except EP0) to be configured for the current configuration (SET_CONFIGURATION). More...
int | dwc_usb3_pcd_ep_disable (dwc_usb3_pcd_t *pcd, dwc_usb3_pcd_ep_t *ep)
| This routine is called when an EP (except EP0) is disabled due to disconnect or change in configuration. Any pending requests will terminate with a status of -ESHUTDOWN. More...
int | dwc_usb3_pcd_ep_submit_req (dwc_usb3_pcd_t *pcd, dwc_usb3_pcd_ep_t *ep, dwc_usb3_pcd_req_t *req, u32 req_flags)
| This routine submits an I/O Request to an EP. More...
void | dwc_usb3_pcd_ep_cancel_req (dwc_usb3_pcd_t *pcd, dwc_usb3_pcd_ep_t *ep, dwc_usb3_pcd_req_t *req, u32 stream)
| This routine cancels an I/O request from an EP. More...
void | dwc_usb3_pcd_request_done (dwc_usb3_pcd_t *pcd, dwc_usb3_pcd_ep_t *ep, dwc_usb3_pcd_req_t *req, int status)
| This routine completes a request. It calls the request callback. More...
void | dwc_usb3_pcd_ep_start_transfer (dwc_usb3_pcd_t *pcd, dwc_usb3_pcd_ep_t *ep, dwc_usb3_pcd_req_t *req, u32 event)
| This routine does the setup for a data transfer for an EP and starts the transfer. More...
void | dwc_usb3_pcd_ep_set_stall (dwc_usb3_pcd_t *pcd, dwc_usb3_pcd_ep_t *ep)
| Set the EP to STALL. More...
void | dwc_usb3_pcd_ep_clear_stall (dwc_usb3_pcd_t *pcd, dwc_usb3_pcd_ep_t *ep)
| Clear the EP STALL. More...
void | dwc_usb3_pcd_ep_set_halt (dwc_usb3_pcd_t *pcd, dwc_usb3_pcd_ep_t *ep, int value)
| This function sets or clears a stall condition on an endpoint. More...

## Function Documentation

## ◆ dwc_usb3_ep_activate()

void dwc_usb3_ep_activate | ( | dwc_usb3_pcd_t * | pcd,
|  | dwc_usb3_pcd_ep_t * | ep,
|  | int | restore
| ) |  |

This routine activates an EP. The Device EP control registers for the EP are configured as defined in the EP structure.

Parameters

  pcd | Programming view of DWC_usb3 peripheral controller.
  ep | The EP to activate.
  restore | True if restoring endpoint state after hibernation.

## ◆ dwc_usb3_pcd_ep_enable()

int dwc_usb3_pcd_ep_enable | ( | dwc_usb3_pcd_t * | pcd,
|  | dwc_usb3_pcd_ep_t * | ep,
|  | const usb_endpoint_descriptor_t * | ep_desc,
|  | const ss_endpoint_companion_descriptor_t * | ep_comp
| ) |  |

This routine is called by the Function Driver for each EP (except EP0) to be configured for the current configuration (SET_CONFIGURATION).

This routine initializes the dwc_usb3_ep_t data structure, and then calls dwc_usb3_ep_activate.

Parameters

  pcd | Programming view of DWC_usb3 peripheral controller.
  ep | The EP to enable.
  ep_desc | Pointer to the USB endpoint descriptor.
  ep_comp | Pointer to the USB SuperSpeed endpoint companion descriptor.

Returns
  0 on success, negative error code on failure.

## ◆ dwc_usb3_pcd_ep_disable()

int dwc_usb3_pcd_ep_disable | ( | dwc_usb3_pcd_t * | pcd,
|  | dwc_usb3_pcd_ep_t * | ep
| ) |  |

This routine is called when an EP (except EP0) is disabled due to disconnect or change in configuration. Any pending requests will terminate with a status of -ESHUTDOWN.

This routine modifies the dwc_usb3_ep_t data structure for this EP, and then calls ep_deactivate.

Parameters

  pcd | Programming view of DWC_usb3 peripheral controller.
  ep | The EP to disable.

Returns
  0 on success, negative error code on failure.

## ◆ dwc_usb3_pcd_ep_submit_req()

int dwc_usb3_pcd_ep_submit_req | ( | dwc_usb3_pcd_t * | pcd,
|  | dwc_usb3_pcd_ep_t * | ep,
|  | dwc_usb3_pcd_req_t * | req,
|  | u32 | req_flags
| ) |  |

This routine submits an I/O Request to an EP.

- When the request completes the request's completion callback is called to return the request to the driver.
- An EP, except control EPs, may have multiple requests pending.
- Once submitted the request cannot be examined or modified.
- Each request is turned into one or more packets.
- A BULK EP can queue any amount of data; the transfer is packetized.
- Zero-length packets are specified with the request 'zero' flag.

Parameters

  pcd | Programming view of DWC_usb3 peripheral controller.
  ep | The EP to submit the request to.
  req | The request to submit.
  req_flags | Flags for the request.

Returns
  0 on success, negative error code on failure.

## ◆ dwc_usb3_pcd_ep_cancel_req()

void dwc_usb3_pcd_ep_cancel_req | ( | dwc_usb3_pcd_t * | pcd,
|  | dwc_usb3_pcd_ep_t * | ep,
|  | dwc_usb3_pcd_req_t * | req,
|  | u32 | stream
| ) |  |

This routine cancels an I/O request from an EP.

Parameters

  pcd | Programming view of DWC_usb3 peripheral controller.
  ep | The EP to cancel the request on.
  req | The request to cancel.
  stream | The stream number for the request.

## ◆ dwc_usb3_pcd_request_done()

void dwc_usb3_pcd_request_done | ( | dwc_usb3_pcd_t * | pcd,
|  | dwc_usb3_pcd_ep_t * | ep,
|  | dwc_usb3_pcd_req_t * | req,
|  | int | status
| ) |  |

This routine completes a request. It calls the request callback.

Parameters

  pcd | Programming view of DWC_usb3 peripheral controller.
  ep | The EP to complete the request on.
  req | The request to complete.
  status | The status of the request completion.

## ◆ dwc_usb3_pcd_ep_start_transfer()

void dwc_usb3_pcd_ep_start_transfer | ( | dwc_usb3_pcd_t * | pcd,
|  | dwc_usb3_pcd_ep_t * | ep,
|  | dwc_usb3_pcd_req_t * | req,
|  | u32 | event
| ) |  |

This routine does the setup for a data transfer for an EP and starts the transfer.

Parameters

  pcd | Programming view of DWC_usb3 peripheral controller.
  ep | The EP to start the transfer on.
  req | The request to start.
  event | If non-zero, this is the first transfer for an Isoc EP, so we must calculate the starting uFrame and do a startxfer instead of an updatexfer.

## ◆ dwc_usb3_pcd_ep_set_stall()

void dwc_usb3_pcd_ep_set_stall | ( | dwc_usb3_pcd_t * | pcd,
|  | dwc_usb3_pcd_ep_t * | ep
| ) |  |

Set the EP to STALL.

Parameters

  pcd | Programming view of DWC_usb3 peripheral controller.
  ep | The EP to set the stall on.

## ◆ dwc_usb3_pcd_ep_clear_stall()

void dwc_usb3_pcd_ep_clear_stall | ( | dwc_usb3_pcd_t * | pcd,
|  | dwc_usb3_pcd_ep_t * | ep
| ) |  |

Clear the EP STALL.

Parameters

  pcd | Programming view of DWC_usb3 peripheral controller.
  ep | The EP to clear the stall on.

## ◆ dwc_usb3_pcd_ep_set_halt()

void dwc_usb3_pcd_ep_set_halt | ( | dwc_usb3_pcd_t * | pcd,
|  | dwc_usb3_pcd_ep_t * | ep,
|  | int | value
| ) |  |

This function sets or clears a stall condition on an endpoint.

This function can be used to stall an endpoint, clear a stall condition, or manage the stall lock flag for the endpoint. The behavior depends on the value argument provided:

Parameters

  pcd | The PCD structure representing the USB peripheral controller.
  ep | The endpoint to set or clear the stall condition.
  value | - 0: Clears the stall condition and resets the data toggle. 1: Sets the stall condition on the endpoint. 2: Clears the stall lock flag. 3: Sets the stall lock flag and stalls the endpoint.