libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
usb_dwc_common.c File Reference
#include <string.h>
#include <libopencm3/cm3/common.h>
#include <libopencm3/usb/usbd.h>
#include <libopencm3/usb/dwc/otg_common.h>
#include "usb_private.h"
#include "usb_dwc_common.h"
Include dependency graph for usb_dwc_common.c:

Go to the source code of this file.

Macros

#define dev_base_address   (usbd_dev->driver->base_address)
 
#define REBASE(x)   MMIO32((x) + (dev_base_address))
 

Functions

void dwc_set_address (usbd_device *usbd_dev, uint8_t addr)
 
void dwc_ep_setup (usbd_device *usbd_dev, uint8_t addr, uint8_t type, uint16_t max_size, void(*callback)(usbd_device *usbd_dev, uint8_t ep))
 
void dwc_endpoints_reset (usbd_device *usbd_dev)
 
void dwc_ep_stall_set (usbd_device *usbd_dev, uint8_t addr, uint8_t stall)
 
uint8_t dwc_ep_stall_get (usbd_device *usbd_dev, uint8_t addr)
 
void dwc_ep_nak_set (usbd_device *usbd_dev, uint8_t addr, uint8_t nak)
 
uint16_t dwc_ep_write_packet (usbd_device *usbd_dev, uint8_t addr, const void *buf, uint16_t len)
 
uint16_t dwc_ep_read_packet (usbd_device *usbd_dev, uint8_t addr, void *buf, uint16_t len)
 
static void dwc_flush_txfifo (usbd_device *usbd_dev, int ep)
 
void dwc_poll (usbd_device *usbd_dev)
 
void dwc_disconnect (usbd_device *usbd_dev, bool disconnected)
 

Macro Definition Documentation

◆ dev_base_address

#define dev_base_address   (usbd_dev->driver->base_address)

Definition at line 30 of file usb_dwc_common.c.

◆ REBASE

#define REBASE (   x)    MMIO32((x) + (dev_base_address))

Definition at line 31 of file usb_dwc_common.c.

Function Documentation

◆ dwc_disconnect()

void dwc_disconnect ( usbd_device usbd_dev,
bool  disconnected 
)

Definition at line 441 of file usb_dwc_common.c.

References OTG_DCTL, OTG_DCTL_SDIS, and REBASE.

◆ dwc_endpoints_reset()

◆ dwc_ep_nak_set()

void dwc_ep_nak_set ( usbd_device usbd_dev,
uint8_t  addr,
uint8_t  nak 
)

Definition at line 177 of file usb_dwc_common.c.

References OTG_DOEPCTL, OTG_DOEPCTL0_CNAK, OTG_DOEPCTL0_SNAK, REBASE, and usbd_dev.

◆ dwc_ep_read_packet()

uint16_t dwc_ep_read_packet ( usbd_device usbd_dev,
uint8_t  addr,
void *  buf,
uint16_t  len 
)

Definition at line 241 of file usb_dwc_common.c.

References OTG_FIFO, REBASE, and usbd_dev.

Referenced by dwc_poll().

Here is the caller graph for this function:

◆ dwc_ep_setup()

◆ dwc_ep_stall_get()

uint8_t dwc_ep_stall_get ( usbd_device usbd_dev,
uint8_t  addr 
)

Definition at line 165 of file usb_dwc_common.c.

References OTG_DIEPCTL, OTG_DIEPCTL0_STALL, OTG_DOEPCTL, OTG_DOEPCTL0_STALL, and REBASE.

◆ dwc_ep_stall_set()

void dwc_ep_stall_set ( usbd_device usbd_dev,
uint8_t  addr,
uint8_t  stall 
)

◆ dwc_ep_write_packet()

uint16_t dwc_ep_write_packet ( usbd_device usbd_dev,
uint8_t  addr,
const void *  buf,
uint16_t  len 
)

◆ dwc_flush_txfifo()

static void dwc_flush_txfifo ( usbd_device usbd_dev,
int  ep 
)
static

Definition at line 300 of file usb_dwc_common.c.

References OTG_DIEPCTL, OTG_DIEPCTL0_SNAK, OTG_DIEPCTL0_TXFNUM_MASK, OTG_DIEPINT, OTG_DIEPINTX_INEPNE, OTG_DIEPTSIZ, OTG_GRSTCTL, OTG_GRSTCTL_AHBIDL, OTG_GRSTCTL_TXFFLSH, and REBASE.

Referenced by dwc_poll().

Here is the caller graph for this function:

◆ dwc_poll()

◆ dwc_set_address()

void dwc_set_address ( usbd_device usbd_dev,
uint8_t  addr 
)

Definition at line 33 of file usb_dwc_common.c.

References OTG_DCFG, and REBASE.